Skip to main content

TaskManager

Struct TaskManager 

Source
pub struct TaskManager { /* private fields */ }

Implementations§

Source§

impl TaskManager

Source

pub fn new(backend: Arc<dyn ExternalBackend>) -> Self

Source

pub fn store(&self) -> Option<&Arc<TaskStore>>

Get reference to the task store (if available).

Source

pub fn repo(&self) -> &str

Get reference to the repo identifier.

Source

pub fn with_store( backend: Arc<dyn ExternalBackend>, store: Arc<TaskStore>, repo: String, ) -> Self

Create a TaskManager with the unified store for dual-write support.

Source

pub fn with_events( backend: Arc<dyn ExternalBackend>, store: Arc<TaskStore>, repo: String, event_tx: Sender<TaskEvent>, ) -> Self

Create a TaskManager with event bus support.

Source

pub async fn create_task(&self, req: CreateTaskRequest) -> Result<Task>

Source

pub async fn get_task(&self, id: i64) -> Result<Task>

Source

pub async fn list_tasks(&self, filter: TaskFilter) -> Result<Vec<Task>>

List tasks by status, source, or both. Returns both internal (store) and external (GitHub) tasks.

Source

pub async fn list_all_external_tasks(&self) -> Result<Vec<ExternalTask>>

Get all external tasks across all statuses (for status summary). Reads from the store when available, falling back to the backend.

Source

pub async fn list_external_by_status( &self, status: Status, ) -> Result<Vec<ExternalTask>>

Get external tasks by status (for engine use). Store-first: reads from the store when available, falls back to backend if the store has no tasks (e.g. before first sync).

Source

pub async fn list_all_by_status( &self, status: Status, ) -> Result<Vec<ExternalTask>>

Get all tasks (external + internal) by status. Store-first for external tasks: reads from the store when available, falls back to backend if the store has no tasks. Always includes internal tasks from the store when available.

Source

pub async fn list_routable(&self) -> Result<Vec<ExternalTask>>

Get open tasks that are routable (status = new). Store-first: reads all New tasks (external + internal) from the store, falling back to the backend for external tasks before first sync.

Source

pub async fn update_task_status( &self, id: &ExternalId, status: Status, ) -> Result<()>

Update the status of an internal or external task by its string ID. For "internal:{n}" IDs, updates the store. For all others, calls the backend. Store is always updated when available.

Source

pub async fn update_task_status_and_result( &self, id: &ExternalId, status: Status, updates: &[(&str, Value)], ) -> Result<()>

Source

pub async fn update_task_status_if( &self, id: &ExternalId, status: Status, expected_status: Status, ) -> Result<bool>

Update the status of a task only if it is currently in expected_status.

Returns Ok(true) if the update was applied, Ok(false) if the task had already transitioned to a different status (TOCTOU-safe — no-op on race).

Source

pub async fn update_task_status_with_duration( &self, id: &ExternalId, status: Status, duration_seconds: Option<f64>, ) -> Result<()>

Update the status of a task and include elapsed duration in the event.

Use this at task completion points (success or failure) so the notify subscriber can include accurate timing in channel messages instead of 0.0.

Source

pub async fn mark_task_done_by_store_id( &self, store_id: i64, repo: &str, ext_id: &ExternalId, ) -> Result<()>

Mark an already-resolved task Done directly by its numeric store id and owning repo, bypassing the repo-scoped resolve_task_id lookup that self.repo would otherwise apply. For callers that already hold the correct store row from a cross-repo query — e.g. the global CI-failure unblock sweep — and would otherwise fail to resolve a task belonging to a different repo than this TaskManager.

Source

pub async fn update_task_status_by_store_id( &self, store_id: i64, repo: &str, ext_id: &ExternalId, status: Status, ) -> Result<()>

Update a task’s status directly by its already-resolved numeric store id and owning repo, bypassing the repo-scoped resolve_task_id lookup that self.repo would otherwise apply. For callers that already hold the correct store row from a cross-repo query — e.g. a global sweep over tasks from inactive/removed repos — and would otherwise fail to resolve a task belonging to a different repo than this TaskManager. Does not mirror to the backend (GitHub), since the caller’s backend instance may not correspond to the task’s owning repo.

Source

pub async fn update_task_status_and_result_by_store_id( &self, store_id: i64, repo: &str, ext_id: &ExternalId, status: Status, updates: &[(&str, Value)], ) -> Result<()>

Like Self::update_task_status_by_store_id but also sets additional result fields atomically with the status transition (e.g. block_reason, last_error).

Source

pub async fn list_internal_by_status( &self, status: TaskStatus, ) -> Result<Vec<ExternalTask>>

List internal tasks by status from the store. Returns store::Task items converted to ExternalTask for backward compatibility.

Source

pub async fn list_all_internal(&self) -> Result<Vec<Task>>

List all internal tasks from the store.

Source

pub async fn publish_task( &self, id: i64, labels: &[String], ) -> Result<ExternalId>

Trait Implementations§

Source§

impl Clone for TaskManager

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

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> 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> 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> 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> 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 = !

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