Skip to main content

TaskQueue

Struct TaskQueue 

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

Task queue backed by SQLite for persistence

Implementations§

Source§

impl TaskQueue

Source

pub fn new( sync_db: SyncDb, profile_id: i32, pipeline: Option<SyncPipeline>, ) -> Self

Create a new task queue

Source

pub fn push(&self, task: SyncTask) -> Result<i64>

Add a task to the queue

Source

pub fn pop(&self) -> Result<Option<SyncTask>>

Get the next pending task

Source

pub fn pop_with_pipeline( &self, pipeline: Option<SyncPipeline>, ) -> Result<Option<SyncTask>>

Get the next pending task for a specific pipeline

Source

pub fn pop_round_robin(&mut self) -> Result<Option<SyncTask>>

Pop the next task using round-robin across primary task types

Source

pub fn pop_round_robin_with_pipeline( &mut self, pipeline: Option<SyncPipeline>, ) -> Result<Option<SyncTask>>

Pop the next task using round-robin across primary task types for a pipeline

Source

pub fn mark_in_progress(&self, task_id: i64) -> Result<()>

Mark a task as in progress

Source

pub fn mark_completed(&self, task_id: i64) -> Result<()>

Mark a task as completed

Source

pub fn mark_failed( &self, task_id: i64, error: &str, retry_after: Duration, ) -> Result<()>

Mark a task as failed with retry

Source

pub fn recover_in_progress(&self) -> Result<u32>

Recover tasks that were in progress (crashed)

Source

pub fn pending_count(&self) -> Result<u32>

Get count of pending tasks

Source

pub fn pending_count_with_pipeline( &self, pipeline: Option<SyncPipeline>, ) -> Result<u32>

Get count of pending tasks for a pipeline

Source

pub fn set_profile_id(&mut self, profile_id: i32)

Update the profile scope for queue operations

Source

pub fn set_pipeline(&mut self, pipeline: Option<SyncPipeline>)

Update the pipeline scope for queue operations

Source

pub fn count_by_status(&self) -> Result<(u32, u32, u32, u32)>

Get task counts by status

Source

pub fn count_by_type(&self) -> Result<(u32, u32, u32, u32)>

Get task counts by type (activities, gpx, health, performance)

Source

pub fn cleanup(&self, days: i32) -> Result<u32>

Clear completed tasks older than given days

Source

pub fn sync_db(&self) -> &SyncDb

Get the sync database (for sync state operations)

Source

pub fn reset_failed(&self) -> Result<u32>

Reset all failed tasks to pending

Source

pub fn clear_pending(&self) -> Result<u32>

Clear all pending and failed tasks

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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> Same for T

Source§

type Output = T

Should always be Self
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