Skip to main content

Config

Struct Config 

Source
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

Source

pub fn new() -> Self

Return the default runtime configuration with a generated temporary directory.

Source

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.

Source

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.

Source

pub const fn with_ring_config(self, config: RingConfig) -> Self

Set io_uring ring capacity and deadline granularity. See RingConfig.

Source

pub const fn with_idle_spinner(self, config: SpinnerConfig) -> Self

Set idle spinning policy. Use SpinnerConfig::disabled to disable it.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn with_tcp_nodelay(self, enabled: Option<bool>) -> Self

Set the best-effort TCP_NODELAY override. None leaves the system default.

Source

pub const fn with_zero_linger(self, enabled: bool) -> Self

Set whether sockets request zero linger when configured.

Source

pub const fn with_read_buffer_size(self, size: usize) -> Self

Set the network receive buffer size in bytes.

Source

pub fn with_storage_directory(self, directory: impl Into<PathBuf>) -> Self

Set the storage directory, created and held when the runner starts.

Source

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.

Source

pub const fn worker_threads(&self) -> usize

Return the number of pool workers, including the calling thread.

Source

pub const fn global_queue_interval(&self) -> u32

Return how often a busy pool worker looks at the global queue first: every Nth poll.

Source

pub const fn ring_config(&self) -> &RingConfig

Return per-worker io_uring ring configuration.

Source

pub const fn idle_spinner(&self) -> &SpinnerConfig

Return per-worker idle spinning configuration.

Source

pub const fn thread_stack_size(&self) -> usize

Return the configured pool, dedicated worker, and Rayon thread stack size.

Source

pub const fn catch_panics(&self) -> bool

Return whether spawned-task panics and dedicated worker failures are caught.

Source

pub const fn connect_timeout(&self) -> Duration

Return the whole-call outbound connection timeout.

Source

pub const fn read_write_timeout(&self) -> Duration

Return the whole-call send and receive timeout.

Source

pub const fn tcp_nodelay(&self) -> Option<bool>

Return the TCP_NODELAY override.

Source

pub const fn zero_linger(&self) -> bool

Return whether sockets request zero linger.

Source

pub const fn read_buffer_size(&self) -> usize

Return the network receive buffer size.

Source

pub const fn storage_directory(&self) -> &PathBuf

Return the storage directory retained by the runtime’s storage resources.

Source

pub const fn storage_blob_layouts(&self) -> &RangeInclusive<BlobLayout> ⓘ

Return the accepted blob layout range.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Threaded<T> for T

Source§

type Rest = ()

The outputs beyond the threaded value.
Source§

fn split(self) -> (T, ())

Splits into the threaded value and the extra outputs.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more