Skip to main content

QueueRuntime

Struct QueueRuntime 

Source
pub struct QueueRuntime { /* private fields */ }
Expand description

Top-level handle for the queue subsystem.

Implementations§

Source§

impl QueueRuntime

Source

pub fn new( storage: Storage, handlers: HandlerRegistry, router: Arc<dyn Router>, ) -> Self

Build a new runtime. host_id is freshly minted from a ULID so each process boot has its own identity in the process registry.

Source

pub fn with_queues(self, queues: impl IntoIterator<Item = String>) -> Self

Declare the queues this worker is responsible for. Required — a worker that declares none fails at start. Names are de-duplicated, preserving first-seen order. Only supervisors for these queues are spawned, and the rebalancer only hands this pod slots for them.

Source

pub fn with_worker_prefix(self, prefix: impl Into<String>) -> Self

Set this worker’s label prefix, shown in the monitoring view. The full label is composed as {prefix}-worker-{version}-{id} (k8s-style), so two workers sharing a prefix stay distinct via the trailing host_id. Accepts a &'static str const, so a service can bake its identity in at compile time: .with_worker_prefix("rates")rates-worker-{ver}-{id}. Unset → the view falls back to host_id. See also with_worker_version / worker_prefix_from_env.

Source

pub fn with_worker_version(self, version: impl Into<String>) -> Self

Set the build version segment of the composed worker label — typically the git commit the binary was built at. Omitted from the label when unset. Has no effect unless a prefix is also set (the label only exists with a prefix). See with_worker_prefix / worker_version_from_env.

Source

pub fn with_worker_id(self, id: impl Into<String>) -> Self

Override the autogenerated id segment of the composed worker label — e.g. a k8s pod id from FORGE_WORKER_ID, so the label tracks pod identity. Unset → forge autogenerates a short id (4 hex) from the per-boot host_id. Has no effect unless a prefix is also set. See worker_id_from_env.

Source

pub async fn ensure_queue( &self, name: &str, default_max_workers: i32, ) -> Result<()>

Ensure a queue config row exists. Safe to call before or after start; the supervisor for a newly-added queue is not spawned until the next start invocation.

Source

pub async fn enqueue(&self, req: EnqueueRequest) -> Result<EnqueueOutcome>

Insert a job and wake the destination queue.

Source

pub async fn start(self) -> Result<QueueHandle>

Spawn one supervisor per registered queue + reaper + cleanup

Trait Implementations§

Source§

impl Clone for QueueRuntime

Source§

fn clone(&self) -> QueueRuntime

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 Debug for QueueRuntime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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> 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> 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.
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