pub struct QueueRuntime { /* private fields */ }Expand description
Top-level handle for the queue subsystem.
Implementations§
Source§impl QueueRuntime
impl QueueRuntime
Sourcepub fn new(
storage: Storage,
handlers: HandlerRegistry,
router: Arc<dyn Router>,
) -> Self
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.
Sourcepub fn with_queues(self, queues: impl IntoIterator<Item = String>) -> Self
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.
Sourcepub fn with_worker_prefix(self, prefix: impl Into<String>) -> Self
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.
Sourcepub fn with_worker_version(self, version: impl Into<String>) -> Self
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.
Sourcepub fn with_worker_id(self, id: impl Into<String>) -> Self
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.
Sourcepub async fn ensure_queue(
&self,
name: &str,
default_max_workers: i32,
) -> Result<()>
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.
Sourcepub async fn enqueue(&self, req: EnqueueRequest) -> Result<EnqueueOutcome>
pub async fn enqueue(&self, req: EnqueueRequest) -> Result<EnqueueOutcome>
Insert a job and wake the destination queue.
Sourcepub async fn start(self) -> Result<QueueHandle>
pub async fn start(self) -> Result<QueueHandle>
Spawn one supervisor per registered queue + reaper + cleanup
- cron. Returns a
QueueHandlefor orchestration.
Trait Implementations§
Source§impl Clone for QueueRuntime
impl Clone for QueueRuntime
Source§fn clone(&self) -> QueueRuntime
fn clone(&self) -> QueueRuntime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for QueueRuntime
impl !UnwindSafe for QueueRuntime
impl Freeze for QueueRuntime
impl Send for QueueRuntime
impl Sync for QueueRuntime
impl Unpin for QueueRuntime
impl UnsafeUnpin for QueueRuntime
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> 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