pub struct SpawnConfig {
pub tenant_id: TenantId,
pub deadline: Option<Duration>,
pub args: Vec<WasmArg>,
pub streaming: Option<StreamingContext>,
pub input: Vec<u8>,
}Expand description
Configuration passed to TensorWasmExecutor::spawn_instance.
Fields§
§tenant_id: TenantIdOwning tenant.
deadline: Option<Duration>Optional per-call deadline.
args: Vec<WasmArg>Arguments forwarded to the first TensorWasmExecutor::call_export_with_args
invocation against this instance.
Callers that drive a single spawn-then-call flow (CLI run, API
/invoke) populate this field so the caller’s argument list survives
the trip across crate boundaries without a parallel CallConfig.
Multi-call flows should ignore this field and pass arguments directly
to each call_export_with_args invocation.
streaming: Option<StreamingContext>Optional streaming context (roadmap feature #2). When Some,
TensorWasmExecutor::spawn_instance builds a wasmtime
wasmtime::Linker that wires the wasi:tensor/host host
functions (emit-chunk, flush) against this context — guest
emits land on the matching mpsc::Receiver<Vec<u8>> the
gateway is draining into the SSE / chunked HTTP response.
None means streaming is disabled: the spawn uses the
historical empty-imports Instance::new_async path, and a
guest that imports wasi:tensor/host will fail to link.
/invoke (the synchronous route) takes the None path; only
/invoke-stream opts in.
input: Vec<u8>Bytes staged for the guest to pull via the wasi:tensor/host
pull-model input channel (input-len / read-input).
Empty by default (the historical behaviour: the guest has no
input channel). When non-empty,
TensorWasmExecutor::spawn_instance installs an
InputContext on
the per-instance state and registers the input-len /
read-input host functions on the spawn linker — so a guest can
copy these bytes into its own linear memory at the start of the
invocation. The OpenAI completions shim sets this to the assembled
prompt bytes.
Implementations§
Source§impl SpawnConfig
impl SpawnConfig
Sourcepub fn for_tenant(tenant_id: TenantId) -> Self
pub fn for_tenant(tenant_id: TenantId) -> Self
Construct with just a tenant and no deadline.
Sourcepub fn with_deadline(self, deadline: Duration) -> Self
pub fn with_deadline(self, deadline: Duration) -> Self
Add a deadline relative to “now at spawn time”.
Sourcepub fn with_args(self, args: Vec<WasmArg>) -> Self
pub fn with_args(self, args: Vec<WasmArg>) -> Self
Attach an argument list for the upcoming call. See SpawnConfig::args.
Sourcepub fn with_streaming(self, ctx: StreamingContext) -> Self
pub fn with_streaming(self, ctx: StreamingContext) -> Self
Attach a streaming context (roadmap feature #2). See
SpawnConfig::streaming.
Builder method; pairs with Self::for_tenant /
Self::with_deadline. The API gateway’s /invoke-stream
route constructs an mpsc::channel, wraps the sender in a
StreamingContext via StreamingContext::with_channel, and
passes it here so the guest’s wasi:tensor/host.emit-chunk
calls land on the matching receiver — which the gateway
concurrently drains into the SSE / chunked response body.
Sourcepub fn with_input(self, input: Vec<u8>) -> Self
pub fn with_input(self, input: Vec<u8>) -> Self
Stage input bytes for the guest to pull via the
wasi:tensor/host input channel (input-len / read-input). See
SpawnConfig::input.
Builder method; pairs with Self::for_tenant /
Self::with_deadline / Self::with_streaming. An empty slice
is a no-op (the default) — the guest then observes input-len() == 0. The OpenAI completions shim passes the assembled prompt bytes
here so the guest receives the prompt.
Trait Implementations§
Source§impl Clone for SpawnConfig
impl Clone for SpawnConfig
Source§fn clone(&self) -> SpawnConfig
fn clone(&self) -> SpawnConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpawnConfig
impl RefUnwindSafe for SpawnConfig
impl Send for SpawnConfig
impl Sync for SpawnConfig
impl Unpin for SpawnConfig
impl UnsafeUnpin for SpawnConfig
impl UnwindSafe for SpawnConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more