Skip to content

Commit

Permalink
fix: fixed max packet size on imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoverson committed Oct 31, 2023
1 parent 2640b75 commit 3fc4cd4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
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

0 comments on commit 3fc4cd4

Please sign in to comment.