#[non_exhaustive]pub struct ServeOptions { /* private fields */ }Expand description
Configuration for a module’s connection lifecycle. Existing serve*
functions use the defaults; use these builder methods to customize serving.
Implementations§
Source§impl ServeOptions
impl ServeOptions
Sourcepub fn with_writer_drain_timeout(self, timeout: Duration) -> Self
pub fn with_writer_drain_timeout(self, timeout: Duration) -> Self
Set the writer drain budget (default: two seconds). A module stop also gives in-flight handlers up to this long to finish before sending GOODBYE, then gives the writer its own budget to flush. Other connection ends cancel handlers immediately. Work still running at a drain deadline is aborted.
Keep the combined handler and writer waits below the daemon’s per-module stop budget: the daemon caps it at 25 seconds, and a module may be configured with less. Leave room for lifecycle hooks as well.
Sourcepub fn with_stop_handle(self, handle: ModuleStopHandle) -> Self
pub fn with_stop_handle(self, handle: ModuleStopHandle) -> Self
Install a stop handle created before calling serve or serve_with,
so a stop also interrupts connection establishment and HELLO.
Sourcepub async fn serve<H: ModuleHandler>(
self,
manifest: ModuleManifest,
handler: H,
) -> Result<(), SubcModuleError>
pub async fn serve<H: ModuleHandler>( self, manifest: ModuleManifest, handler: H, ) -> Result<(), SubcModuleError>
Serve using the same launch arguments and environment as serve.
Sourcepub async fn serve_with<H: ModuleHandler>(
self,
connection_file: &Path,
manifest: ModuleManifest,
handler: H,
) -> Result<(), SubcModuleError>
pub async fn serve_with<H: ModuleHandler>( self, connection_file: &Path, manifest: ModuleManifest, handler: H, ) -> Result<(), SubcModuleError>
Serve with an explicit connection file and an unchanged manifest.
Sourcepub async fn serve_from_env_with_handle<H: ModuleHandler>(
self,
manifest: ModuleManifest,
handler: H,
) -> Result<Option<(ModuleHandle, ModuleServeFuture)>, SubcModuleError>
pub async fn serve_from_env_with_handle<H: ModuleHandler>( self, manifest: ModuleManifest, handler: H, ) -> Result<Option<(ModuleHandle, ModuleServeFuture)>, SubcModuleError>
Connect and register using the same launch inputs as Self::serve,
returning a cloneable handle and the future that keeps the module serving.
Reads --subc <connection-file> (or --subc=<connection-file>) from argv
and overrides the manifest’s module id with SUBC_MODULE_ID when present.
Uses this options value’s stop handle and writer drain timeout. A requested
stop before registration completes returns Ok(None); this is an expected
outcome, not a connection error.
The returned serve future must be awaited or spawned. A module can give the returned handle to its handler’s shared state before starting that future. Spawn the serve future before slow startup work or awaiting control RPCs: it reads their replies and answers health and stop.
Sourcepub async fn serve_with_handle<H: ModuleHandler>(
self,
connection_file: &Path,
manifest: ModuleManifest,
handler: H,
) -> Result<Option<(ModuleHandle, ModuleServeFuture)>, SubcModuleError>
pub async fn serve_with_handle<H: ModuleHandler>( self, connection_file: &Path, manifest: ModuleManifest, handler: H, ) -> Result<Option<(ModuleHandle, ModuleServeFuture)>, SubcModuleError>
Connect with an explicit connection file and an unchanged manifest, returning a cloneable handle and the future that keeps the module serving.
Uses this options value’s stop handle and writer drain timeout. A requested
stop before registration completes returns Ok(None); this is an expected
outcome, not a connection error.
The returned serve future must be awaited or spawned. A module can give the returned handle to its handler’s shared state before starting that future. Spawn the serve future before slow startup work or awaiting control RPCs: it reads their replies and answers health and stop.