[][src]Struct izta::runner::Runner

pub struct Runner<F> where
    F: Fn(&Task) -> RunTaskResult,
    F: Send + 'static + Sync + Clone + Copy
{ /* fields omitted */ }

Runner spawns the task executor and allows new tasks to be scheduled.

Methods

impl<F> Runner<F> where
    F: Fn(&Task) -> RunTaskResult,
    F: Send + 'static + Sync + Clone + Copy
[src]

pub fn new(
    f: F,
    db_url: &str,
    table_name: &str,
    queues: Vec<String>
) -> Runner<F> where
    F: Fn(&Task) -> RunTaskResult,
    F: Send + 'static + Sync + Clone + Copy
[src]

Returns a new Runner. Must call start() to begin executing tasks.

Arguments

  • f - Callback generated by process_jobs!. See Examples below.
  • db_url - Address of Postgres database containing tasks table. Syntax: postgres://username:password@hostname:port/db_name
  • table_name - The name of the Postgres table containing tasks.
  • queues - If empty, process any task. If not empty, only process tasks belonging to specified queues.

Example


// Provided that JobA and JobB are two types implementing the Job trait
let runner = Runner::new(
    process_jobs!(JobA, JobB),
    "postgres://izta:password@localhost:5432/izta_test",
    "tasks",
    vec![],
);

pub fn start(&self)[src]

Begin executing tasks.

pub fn add_task(&self, req: &TaskReq) -> Task[src]

Creates and schedules a new Task for execution from a TaskReq. Returns new task

pub fn finished(&self) -> Vec<Task>[src]

Return all finished tasks managed by this Runner

pub fn failed(&self) -> Vec<Task>[src]

Return all failed tasks managed by this Runner

Auto Trait Implementations

impl<F> Send for Runner<F>

impl<F> !Sync for Runner<F>

impl<F> Unpin for Runner<F> where
    F: Unpin

impl<F> !UnwindSafe for Runner<F>

impl<F> !RefUnwindSafe for Runner<F>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self