pub struct ApiSpawnConfig {
pub command: TsgoCommand,
pub mode: ApiMode,
pub filesystem: Option<Arc<dyn ApiFileSystem>>,
pub request_timeout: Option<Duration>,
pub shutdown_timeout: Duration,
pub outbound_capacity: usize,
pub allow_unstable_upstream_calls: bool,
pub observer: Option<Arc<dyn TsgoObserver>>,
pub profiler: Option<Arc<dyn ApiProfiler>>,
}Expand description
Process configuration for spawning a tsgo API worker.
A single config describes both the executable to launch and the transport strategy used to communicate with it. The default is sync msgpack because it minimizes framing overhead for latency-sensitive, repeated requests.
§Examples
use corsa_client::{ApiMode, ApiSpawnConfig};
let config = ApiSpawnConfig::new("/opt/bin/tsgo")
.with_cwd("/workspace")
.with_mode(ApiMode::AsyncJsonRpcStdio);
assert_eq!(config.mode, ApiMode::AsyncJsonRpcStdio);
assert_eq!(config.command.cwd().to_string_lossy(), "/workspace");Fields§
§command: TsgoCommandReusable command template used to launch the worker.
mode: ApiModeWire protocol used between the client and tsgo.
filesystem: Option<Arc<dyn ApiFileSystem>>Optional filesystem callback implementation exposed to tsgo.
This is primarily useful when the worker should consult an overlay or a virtualized filesystem instead of only reading from disk.
request_timeout: Option<Duration>Maximum time to wait for a single request before surfacing a timeout.
shutdown_timeout: DurationMaximum time to wait for process shutdown before force-killing the worker.
outbound_capacity: usizeMaximum number of queued outbound transport messages.
allow_unstable_upstream_calls: boolAllows calls to upstream endpoints that are known to be unstable.
observer: Option<Arc<dyn TsgoObserver>>Optional observer for structured transport events.
profiler: Option<Arc<dyn ApiProfiler>>Optional profiler for fine-grained request phase samples.
Implementations§
Source§impl ApiSpawnConfig
impl ApiSpawnConfig
Sourcepub fn new(executable: impl Into<PathBuf>) -> ApiSpawnConfig
pub fn new(executable: impl Into<PathBuf>) -> ApiSpawnConfig
Creates a new spawn config with the fastest stdio transport enabled by default.
The sync msgpack transport avoids JSON framing and base64 binary payloads, which makes it the preferred mode for benchmark and production usage.
Sourcepub fn with_cwd(self, cwd: impl Into<PathBuf>) -> ApiSpawnConfig
pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> ApiSpawnConfig
Sets the worker current directory.
Sourcepub fn with_mode(self, mode: ApiMode) -> ApiSpawnConfig
pub fn with_mode(self, mode: ApiMode) -> ApiSpawnConfig
Selects the transport mode used for stdio communication.
Sourcepub fn with_filesystem(
self,
filesystem: Arc<dyn ApiFileSystem>,
) -> ApiSpawnConfig
pub fn with_filesystem( self, filesystem: Arc<dyn ApiFileSystem>, ) -> ApiSpawnConfig
Installs filesystem callbacks that tsgo can call back into.
Sourcepub fn with_request_timeout(self, timeout: Option<Duration>) -> ApiSpawnConfig
pub fn with_request_timeout(self, timeout: Option<Duration>) -> ApiSpawnConfig
Sets the per-request timeout applied by the client transport.
Sourcepub fn with_shutdown_timeout(self, timeout: Duration) -> ApiSpawnConfig
pub fn with_shutdown_timeout(self, timeout: Duration) -> ApiSpawnConfig
Sets the graceful shutdown timeout used when closing a worker.
Sourcepub fn with_outbound_capacity(self, capacity: usize) -> ApiSpawnConfig
pub fn with_outbound_capacity(self, capacity: usize) -> ApiSpawnConfig
Sets the maximum number of queued outbound transport messages.
Sourcepub fn with_allow_unstable_upstream_calls(self, allow: bool) -> ApiSpawnConfig
pub fn with_allow_unstable_upstream_calls(self, allow: bool) -> ApiSpawnConfig
Allows calls to upstream endpoints marked unstable by this crate.
Sourcepub fn with_observer(self, observer: Arc<dyn TsgoObserver>) -> ApiSpawnConfig
pub fn with_observer(self, observer: Arc<dyn TsgoObserver>) -> ApiSpawnConfig
Sets the observer used for structured transport events.
Sourcepub fn with_profiler(self, profiler: Arc<dyn ApiProfiler>) -> ApiSpawnConfig
pub fn with_profiler(self, profiler: Arc<dyn ApiProfiler>) -> ApiSpawnConfig
Sets the profiler used for fine-grained request phase samples.
Trait Implementations§
Source§impl Clone for ApiSpawnConfig
impl Clone for ApiSpawnConfig
Source§fn clone(&self) -> ApiSpawnConfig
fn clone(&self) -> ApiSpawnConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more