pub struct Executor { /* private fields */ }Expand description
Executor configuration for a durable worker.
Implementations§
Source§impl Executor
impl Executor
pub fn new(db: DatabaseConnection, executor_id: String) -> Self
pub fn db(&self) -> &DatabaseConnection
pub fn executor_id(&self) -> &str
Sourcepub async fn heartbeat(&self) -> Result<(), DurableError>
pub async fn heartbeat(&self) -> Result<(), DurableError>
Write (or upsert) a heartbeat row for this executor.
Sourcepub fn start_heartbeat(&self, config: &HeartbeatConfig) -> JoinHandle<()>
pub fn start_heartbeat(&self, config: &HeartbeatConfig) -> JoinHandle<()>
Spawn a background tokio task that calls heartbeat() every config.heartbeat_interval.
Returns a JoinHandle so the caller can abort it on graceful shutdown.
Sourcepub async fn recover_stale_tasks(
&self,
staleness_threshold: Duration,
) -> Result<u64, DurableError>
pub async fn recover_stale_tasks( &self, staleness_threshold: Duration, ) -> Result<u64, DurableError>
Reset RUNNING tasks from dead workers (stale heartbeat > staleness_threshold) to PENDING.
Excludes own executor_id — own tasks are handled by startup reset. Returns the number of rows affected.
Sourcepub fn start_recovery_loop(&self, config: &HeartbeatConfig) -> JoinHandle<()>
pub fn start_recovery_loop(&self, config: &HeartbeatConfig) -> JoinHandle<()>
Spawn a background tokio task that calls recover_stale_tasks() every
config.staleness_threshold interval.
Sourcepub async fn recover(&self) -> Result<Vec<RecoveredTask>, DurableError>
pub async fn recover(&self) -> Result<Vec<RecoveredTask>, DurableError>
Scan for stale tasks by timeout and reset them to PENDING.
A task is considered stale if:
status = 'RUNNING'timeout_ms IS NOT NULLordeadline_epoch_ms IS NOT NULLstarted_at IS NOT NULL- The timeout/deadline has elapsed
Tasks without timeout_ms set are never considered stale.
Auto Trait Implementations§
impl Freeze for Executor
impl !RefUnwindSafe for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl UnsafeUnpin for Executor
impl !UnwindSafe for Executor
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
Mutably borrows from an owned value. Read more
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>
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 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>
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