Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config V2 #58

Merged
merged 7 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ prost = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }

[dev-dependencies]
kitsune2_test_utils = { workspace = true }
tokio = { workspace = true, features = ["full"] }
37 changes: 21 additions & 16 deletions crates/api/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,36 @@ impl Builder {
/// Construct a default config given the configured module factories.
/// Note, this should be called before freezing the Builder instance
/// in an Arc<>.
pub fn set_default_config(&mut self) -> K2Result<()> {
let Self {
config,
verifier: _,
kitsune,
space,
peer_store,
fetch,
transport,
} = self;
pub fn with_default_config(mut self) -> K2Result<Self> {
{
let Self {
config,
verifier: _,
kitsune,
space,
peer_store,
fetch,
transport,
} = &mut self;

kitsune.default_config(config)?;
space.default_config(config)?;
peer_store.default_config(config)?;
fetch.default_config(config)?;
transport.default_config(config)?;
kitsune.default_config(config)?;
space.default_config(config)?;
peer_store.default_config(config)?;
fetch.default_config(config)?;
transport.default_config(config)?;

Ok(())
config.mark_defaults_set();
}

Ok(self)
}

/// This will generate an actual kitsune instance.
pub async fn build(
self,
handler: kitsune::DynKitsuneHandler,
) -> K2Result<kitsune::DynKitsune> {
self.config.mark_runtime();
let builder = Arc::new(self);
builder.kitsune.create(builder.clone(), handler).await
}
Expand Down
Loading
Loading