pub struct Config { /* private fields */ }Expand description
Configuration for the native io_uring runtime.
A pool of Self::with_worker_threads workers polls ordinary tasks, the
first on the thread calling crate::Runner::start. Tasks marked dedicated
or blocking each receive a fresh thread and io_uring ring. Shutdown
completes retained writes and syncs without a configured time limit.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Self
pub fn new() -> Self
Return the default runtime configuration with a generated temporary directory.
Sourcepub const fn with_worker_threads(self, workers: usize) -> Self
pub const fn with_worker_threads(self, workers: usize) -> Self
Set the number of pool workers, including the calling thread. Defaults to 2.
Must be between 1 and 64. Each worker has its own io_uring ring. Dedicated and blocking threads are additional to this count.
Sourcepub const fn with_global_queue_interval(self, interval: u32) -> Self
pub const fn with_global_queue_interval(self, interval: u32) -> Self
Set how often a busy pool worker looks at the global queue first: every
intervalth poll. Defaults to 31.
Must be nonzero. A smaller interval starts tasks in the global queue sooner at the cost of more synchronization. At 1, a busy worker checks the global queue before every poll and polls its own queued tasks only while the global queue is empty.
Sourcepub const fn with_ring_config(self, config: RingConfig) -> Self
pub const fn with_ring_config(self, config: RingConfig) -> Self
Set io_uring ring capacity and deadline granularity. See RingConfig.
Sourcepub const fn with_idle_spinner(self, config: SpinnerConfig) -> Self
pub const fn with_idle_spinner(self, config: SpinnerConfig) -> Self
Set idle spinning policy. Use SpinnerConfig::disabled to disable it.
Sourcepub const fn with_thread_stack_size(self, size: usize) -> Self
pub const fn with_thread_stack_size(self, size: usize) -> Self
Set the stack size of pool, dedicated worker, and Rayon threads. Worker zero runs on the calling thread and keeps its stack.
Sourcepub const fn with_catch_panics(self, catch: bool) -> Self
pub const fn with_catch_panics(self, catch: bool) -> Self
Set whether spawned-task panics and dedicated worker failures are caught.
Caught failures are logged without interrupting the root. Propagated failures are observed only while the root is executing. A failure of a pool worker itself, such as an io_uring error, fails the runner with either setting. It interrupts the root while the root runs, and otherwise the runner resumes it after shutdown.
A worker that fails to start, for example because its io_uring ring
cannot be created, reports the error through the panic hook. With
panic = "abort", such a failure aborts the process with either
setting, like a failure to spawn the worker’s thread.
During worker execution, cancellation-time and task-disposal panics
escaping the user-poll wrapper are contained with either setting. An
unpublished result may resolve to Error::Closed, while an
already-published result remains available.
Task factories execute synchronously and propagate panics to their caller.
Sourcepub const fn with_connect_timeout(self, timeout: Duration) -> Self
pub const fn with_connect_timeout(self, timeout: Duration) -> Self
Set the outbound connection timeout, including queueing and retries.
Must be nonzero and no greater than 30 years. The maximum configured
network timeout must fit the wheel slot limit in RingConfig.
Sourcepub const fn with_read_write_timeout(self, timeout: Duration) -> Self
pub const fn with_read_write_timeout(self, timeout: Duration) -> Self
Set the send and receive timeout, including queueing and partial progress.
Must be nonzero and no greater than 30 years. The maximum configured
network timeout must fit the wheel slot limit in RingConfig.
Sourcepub const fn with_tcp_nodelay(self, enabled: Option<bool>) -> Self
pub const fn with_tcp_nodelay(self, enabled: Option<bool>) -> Self
Set the best-effort TCP_NODELAY override. None leaves the system default.
Sourcepub const fn with_zero_linger(self, enabled: bool) -> Self
pub const fn with_zero_linger(self, enabled: bool) -> Self
Set whether sockets request zero linger when configured.
Sourcepub const fn with_read_buffer_size(self, size: usize) -> Self
pub const fn with_read_buffer_size(self, size: usize) -> Self
Set the network receive buffer size in bytes.
Sourcepub fn with_storage_directory(self, directory: impl Into<PathBuf>) -> Self
pub fn with_storage_directory(self, directory: impl Into<PathBuf>) -> Self
Set the storage directory, created and held when the runner starts.
Sourcepub fn with_storage_blob_layouts(
self,
layouts: RangeInclusive<BlobLayout>,
) -> Self
pub fn with_storage_blob_layouts( self, layouts: RangeInclusive<BlobLayout>, ) -> Self
Set the blob layouts accepted by storage.
New blobs use the latest layout in this range. Existing blobs outside
it fail to open with crate::Error::BlobLayoutMismatch. Restrict the
range to what a rollback target can read before first opening storage.
§Panics
Panics if layouts is empty.
Sourcepub const fn worker_threads(&self) -> usize
pub const fn worker_threads(&self) -> usize
Return the number of pool workers, including the calling thread.
Sourcepub const fn global_queue_interval(&self) -> u32
pub const fn global_queue_interval(&self) -> u32
Return how often a busy pool worker looks at the global queue first: every Nth poll.
Sourcepub const fn ring_config(&self) -> &RingConfig
pub const fn ring_config(&self) -> &RingConfig
Return per-worker io_uring ring configuration.
Sourcepub const fn idle_spinner(&self) -> &SpinnerConfig
pub const fn idle_spinner(&self) -> &SpinnerConfig
Return per-worker idle spinning configuration.
Sourcepub const fn thread_stack_size(&self) -> usize
pub const fn thread_stack_size(&self) -> usize
Return the configured pool, dedicated worker, and Rayon thread stack size.
Sourcepub const fn catch_panics(&self) -> bool
pub const fn catch_panics(&self) -> bool
Return whether spawned-task panics and dedicated worker failures are caught.
Sourcepub const fn connect_timeout(&self) -> Duration
pub const fn connect_timeout(&self) -> Duration
Return the whole-call outbound connection timeout.
Sourcepub const fn read_write_timeout(&self) -> Duration
pub const fn read_write_timeout(&self) -> Duration
Return the whole-call send and receive timeout.
Sourcepub const fn tcp_nodelay(&self) -> Option<bool>
pub const fn tcp_nodelay(&self) -> Option<bool>
Return the TCP_NODELAY override.
Sourcepub const fn zero_linger(&self) -> bool
pub const fn zero_linger(&self) -> bool
Return whether sockets request zero linger.
Sourcepub const fn read_buffer_size(&self) -> usize
pub const fn read_buffer_size(&self) -> usize
Return the network receive buffer size.
Sourcepub const fn storage_directory(&self) -> &PathBuf
pub const fn storage_directory(&self) -> &PathBuf
Return the storage directory retained by the runtime’s storage resources.
Sourcepub const fn storage_blob_layouts(&self) -> &RangeInclusive<BlobLayout> ⓘ
pub const fn storage_blob_layouts(&self) -> &RangeInclusive<BlobLayout> ⓘ
Return the accepted blob layout range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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