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

Fixed custom max_packet_size on imported components #462

Merged
merged 2 commits into from
Nov 1, 2023
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ wick-component-cli = { path = "./crates/wick/wick-component-cli", version = "0.3
wick-component-codegen = { path = "./crates/wick/wick-component-codegen", version = "0.6.0" }
wick-component-wasmrs = { path = "./crates/wick/wick-component-wasmrs", version = "0.3.0" }
wick-config = { path = "./crates/wick/wick-config", version = "0.28.0", default-features = false }
wick-host = { path = "./crates/wick/wick-host", version = "0.6.0" }
wick-host = { path = "./crates/wick/wick-host", version = "0.6.1" }
wick-interface-types = { path = "./crates/wick/wick-interface-types", version = "0.17.0" }
wick-invocation-server = { path = "./crates/wick/wick-invocation-server", version = "0.3.0" }
wick-oci-utils = { path = "./crates/wick/wick-oci-utils", version = "0.5.0", default-features = false }
Expand All @@ -115,7 +115,7 @@ wick-runtime = { path = "./crates/wick/wick-runtime", version = "0.24.0" }
wick-test = { path = "./crates/wick/wick-test", version = "0.3.0" }
wick-trigger = { path = "./crates/wick/wick-trigger", version = "0.1.0" }
wick-trigger-cli = { path = "./crates/wick/wick-trigger-cli", version = "0.1.0" }
wick-trigger-http = { path = "./crates/wick/wick-trigger-http", version = "0.1.0" }
wick-trigger-http = { path = "./crates/wick/wick-trigger-http", version = "0.1.1" }
wick-trigger-time = { path = "./crates/wick/wick-trigger-time", version = "0.1.0" }
wick-trigger-wasm-command = { path = "./crates/wick/wick-trigger-wasm-command", version = "0.1.1" }
wick-wascap = { path = "./crates/wick/wick-wascap", version = "0.3.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/wick/wick-host/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wick-host"
version = "0.6.0"
version = "0.6.1"
authors = ["Jarrod Overson <[email protected]>"]
edition = "2021"
license = "Elastic-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/wick/wick-runtime/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub(crate) async fn init_manifest_component(
opts.rng_seed = rng.seed();

let uuid = rng.uuid();
let _scope = init_child(uuid, manifest.clone(), id.clone(), opts).await?;
let _scope = init_child(uuid, manifest.clone(), id.clone(), opts, kind.max_packet_size()).await?;

let component = Arc::new(scope_component::ScopeComponent::new(uuid));
let service = NativeComponentService::new(component);
Expand Down
4 changes: 4 additions & 0 deletions crates/wick/wick-runtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub struct RuntimeInit {

#[builder(setter(custom = true))]
pub(crate) initial_components: ComponentRegistry,

#[builder(default)]
pub(crate) max_packet_size: Option<u32>,
}

impl Runtime {
Expand Down Expand Up @@ -248,6 +251,7 @@ impl RuntimeBuilder {
Runtime::new(
seed.unwrap_or_else(new_seed),
RuntimeInit {
max_packet_size: self.max_packet_size.flatten(),
manifest: definition,
allow_latest: self.allow_latest.unwrap_or_default(),
allowed_insecure: self.allowed_insecure.unwrap_or_default(),
Expand Down
6 changes: 5 additions & 1 deletion crates/wick/wick-runtime/src/runtime/scope/child_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ pub(crate) struct ChildInit {
pub(crate) allowed_insecure: Vec<String>,
pub(crate) root_config: Option<RuntimeConfig>,
pub(crate) provided: Option<HandlerMap>,
pub(crate) max_packet_size: Option<u32>,
#[allow(unused)]
pub(crate) span: Span,
}

impl std::fmt::Debug for ChildInit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ComponentInitOptions")
f.debug_struct("ChildInit")
.field("rng_seed", &self.rng_seed)
.field("runtime_id", &self.runtime_id)
.field("allow_latest", &self.allow_latest)
.field("max_packet_size", &self.max_packet_size)
.field("allowed_insecure", &self.allowed_insecure)
.field("root_config", &self.root_config)
.field("provided", &self.provided.as_ref().map(|p| p.inner().keys()))
Expand All @@ -39,6 +41,7 @@ pub(crate) fn init_child(
manifest: ComponentConfiguration,
namespace: String,
opts: ChildInit,
max_packet_size: Option<u32>,
) -> BoxFuture<'static, Result<Scope, ScopeError>> {
let child_span = info_span!(parent:&opts.span,"scope",id=%namespace);
let mut components = ComponentRegistry::default();
Expand All @@ -61,6 +64,7 @@ pub(crate) fn init_child(
constraints: Default::default(),
span: child_span,
initial_components: components,
max_packet_size,
};

let init = ScopeInit::new_with_id(Some(opts.runtime_id), uid, opts.rng_seed, config);
Expand Down
17 changes: 13 additions & 4 deletions crates/wick/wick-runtime/src/runtime/scope/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub(crate) struct ScopeInit {
pub(crate) constraints: Vec<RuntimeConstraint>,
pub(crate) initial_components: ComponentRegistry,
pub(crate) span: Span,
pub(crate) max_packet_size: Option<u32>,
}

impl ScopeInit {
Expand All @@ -43,6 +44,7 @@ impl ScopeInit {
constraints: config.constraints,
initial_components: config.initial_components,
span: config.span,
max_packet_size: config.max_packet_size,
}
}

Expand All @@ -59,10 +61,16 @@ impl ScopeInit {
constraints: config.constraints,
initial_components: config.initial_components,
span: config.span,
max_packet_size: config.max_packet_size,
}
}

pub(super) fn child_init(&self, root_config: Option<RuntimeConfig>, provided: Option<HandlerMap>) -> ChildInit {
pub(super) fn child_init(
&self,
root_config: Option<RuntimeConfig>,
provided: Option<HandlerMap>,
max_packet_size: Option<u32>,
) -> ChildInit {
ChildInit {
rng_seed: self.rng.seed(),
runtime_id: self.id,
Expand All @@ -71,6 +79,7 @@ impl ScopeInit {
allowed_insecure: self.allowed_insecure.clone(),
provided,
span: self.span.clone(),
max_packet_size,
}
}

Expand Down Expand Up @@ -106,7 +115,7 @@ impl ScopeInit {
Some(config.extends())
} else {
// Instantiate non-composite component as an exposed, standalone component.
let child_init = self.child_init(self.manifest.root_config().cloned(), None);
let child_init = self.child_init(self.manifest.root_config().cloned(), None, self.max_packet_size);

self
.span
Expand All @@ -120,7 +129,7 @@ impl ScopeInit {
provided.insert(req.id().to_owned(), Entity::component(req.id()).url());
}

let component = init_impl(&self.manifest, ns.clone(), child_init, None, provided).await?;
let component = init_impl(&self.manifest, ns.clone(), child_init, self.max_packet_size, provided).await?;
component.expose();

expect_signature_match(
Expand All @@ -144,7 +153,7 @@ impl ScopeInit {
) -> Result<HandlerMap, ScopeError> {
for binding in self.manifest.import() {
let provided = generate_provides_handlers(binding.kind().provide(), &components)?;
let component_init = self.child_init(binding.kind().config().cloned(), Some(provided));
let component_init = self.child_init(binding.kind().config().cloned(), Some(provided), self.max_packet_size);
if let Some(component) = instantiate_import(binding, component_init, self.manifest.resolver()).await? {
if let Some(extends) = extends {
if extends.iter().any(|n| n == component.namespace()) {
Expand Down
2 changes: 1 addition & 1 deletion crates/wick/wick-trigger-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wick-trigger-http"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "Elastic-2.0"
repository = "https://github.com/candlecorp/wick"
Expand Down
Loading