Skip to content

Commit

Permalink
Hotfix: initialization of DependencyGraphRepository (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaychenko-sergei authored Jan 18, 2024
1 parent d566aea commit 96a40f4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kamu-adapter-flight-sql = { git = "https://github.com/kamu-data/kamu-cli", tag =


[workspace.package]
version = "0.12.0"
version = "0.12.1"
edition = "2021"
homepage = "https://github.com/kamu-data/kamu-platform"
repository = "https://github.com/kamu-data/kamu-platform"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Business Source License 1.1

Licensor: Kamu Data, Inc.

Licensed Work: Kamu Platform Version 0.12.0
Licensed Work: Kamu Platform Version 0.12.1
The Licensed Work is © 2023 Kamu Data, Inc.

Additional Use Grant: You may use the Licensed Work for any purpose,
Expand Down
58 changes: 58 additions & 0 deletions src/app/api-server/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,19 @@ pub async fn run(matches: clap::ArgMatches) -> Result<(), InternalError> {
BINARY_NAME
);

let dependencies_graph_repository = prepare_dependencies_graph_repository(
kamu::domain::CurrentAccountSubject::logged(
opendatafabric::AccountName::new_unchecked(kamu::domain::auth::DEFAULT_ACCOUNT_NAME),
true,
),
&repo_url,
)
.await;

let catalog = init_dependencies(config, &repo_url, local_dir.path())
.await
.add_value(dependencies_graph_repository)
.bind::<dyn kamu::domain::DependencyGraphRepository, kamu::DependencyGraphRepositoryInMemory>()
.build();

match matches.subcommand() {
Expand Down Expand Up @@ -179,6 +190,53 @@ pub fn load_config(path: Option<&PathBuf>) -> Result<ApiServerConfig, InternalEr

/////////////////////////////////////////////////////////////////////////////////////////

pub async fn prepare_dependencies_graph_repository(
current_account_subject: kamu::domain::CurrentAccountSubject,
repo_url: &Url,
) -> kamu::DependencyGraphRepositoryInMemory {
// Construct a special catalog just to create 1 object, but with a repository
// bound to API server command line user. It also should be authorized to access
// any dataset.

let mut b = CatalogBuilder::new();

match repo_url.scheme() {
"file" => {
let datasets_dir = repo_url.to_file_path().unwrap();

b.add_builder(
kamu::DatasetRepositoryLocalFs::builder()
.with_root(datasets_dir.clone())
.with_multi_tenant(false),
);
b.bind::<dyn kamu::domain::DatasetRepository, kamu::DatasetRepositoryLocalFs>();
}
"s3" | "s3+http" | "s3+https" => {
let s3_context = kamu::utils::s3_context::S3Context::from_url(&repo_url).await;

b.add_builder(
kamu::DatasetRepositoryS3::builder()
.with_s3_context(s3_context.clone())
.with_multi_tenant(true),
)
.bind::<dyn kamu::domain::DatasetRepository, kamu::DatasetRepositoryS3>();
}
_ => panic!("Unsupported repository scheme: {}", repo_url.scheme()),
}

let special_catlaog = b
.add::<event_bus::EventBus>()
.add_value(current_account_subject)
.add::<kamu::domain::auth::AlwaysHappyDatasetActionAuthorizer>()
.add::<kamu::DependencyGraphServiceInMemory>()
// Don't add it's own initializer, leave optional dependency uninitialized
.build();

let dataset_repo = special_catlaog.get_one().unwrap();

kamu::DependencyGraphRepositoryInMemory::new(dataset_repo)
}

pub async fn init_dependencies(
config: ApiServerConfig,
repo_url: &Url,
Expand Down

0 comments on commit 96a40f4

Please sign in to comment.