Skip to main content

ApiSpawnConfig

Struct ApiSpawnConfig 

Source
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: TsgoCommand

Reusable command template used to launch the worker.

§mode: ApiMode

Wire 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: Duration

Maximum time to wait for process shutdown before force-killing the worker.

§outbound_capacity: usize

Maximum number of queued outbound transport messages.

§allow_unstable_upstream_calls: bool

Allows 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

Source

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.

Source

pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> ApiSpawnConfig

Sets the worker current directory.

Source

pub fn with_mode(self, mode: ApiMode) -> ApiSpawnConfig

Selects the transport mode used for stdio communication.

Source

pub fn with_filesystem( self, filesystem: Arc<dyn ApiFileSystem>, ) -> ApiSpawnConfig

Installs filesystem callbacks that tsgo can call back into.

Source

pub fn with_request_timeout(self, timeout: Option<Duration>) -> ApiSpawnConfig

Sets the per-request timeout applied by the client transport.

Source

pub fn with_shutdown_timeout(self, timeout: Duration) -> ApiSpawnConfig

Sets the graceful shutdown timeout used when closing a worker.

Source

pub fn with_outbound_capacity(self, capacity: usize) -> ApiSpawnConfig

Sets the maximum number of queued outbound transport messages.

Source

pub fn with_allow_unstable_upstream_calls(self, allow: bool) -> ApiSpawnConfig

Allows calls to upstream endpoints marked unstable by this crate.

Source

pub fn with_observer(self, observer: Arc<dyn TsgoObserver>) -> ApiSpawnConfig

Sets the observer used for structured transport events.

Source

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

Source§

fn clone(&self) -> ApiSpawnConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.