[][src]Struct zeebe::JobWorkerBuilder

pub struct JobWorkerBuilder { /* fields omitted */ }

Configuration for an asynchronous worker process.

Implementations

impl JobWorkerBuilder[src]

pub fn new(client: Client) -> Self[src]

Create a new job worker builder.

pub fn with_job_type<T: Into<String>>(self, job_type: T) -> Self[src]

Set the job type of the worker.

pub fn with_worker_name<T: Into<String>>(self, worker: T) -> Self[src]

Set the worker name (mostly used for logging)

pub fn with_timeout(self, timeout: Duration) -> Self[src]

Set the worker job timeout.

See the requesting jobs docs for more details.

pub fn with_request_timeout(self, request_timeout: Duration) -> Self[src]

Set the worker request timeout.

See the requesting jobs docs for more details.

pub fn with_max_jobs_active(self, max_jobs_active: u32) -> Self[src]

Set the maximum jobs to activate at a time by the worker.

pub fn with_concurrency(self, concurrency: u32) -> Self[src]

Set the max number of jobs to run concurrently.

pub fn with_handler<T, R>(self, handler: T) -> Self where
    T: Fn(Client, Job) -> R + Send + Sync + 'static,
    R: Future<Output = ()> + Send + 'static, 
[src]

Set the handler function for the worker.

pub fn with_auto_handler<F, R, E, T, J>(self, handler: F) -> Self where
    F: Fn(Client, J) -> R + Send + Sync + 'static,
    R: Future<Output = Result<T, E>> + Send + 'static,
    E: Error,
    T: Serialize,
    J: DeserializeOwned
[src]

Set a handler function that completes or fails the job based on the result rather than having to explicitly use the client to report job status.

Examples

use serde::{Deserialize, Serialize};
use thiserror::Error;
use zeebe::Client;
use futures::future;

let client = Client::new();

// Given an app-specific error
#[derive(Error, Debug)]
enum MyError {
    #[error("unknown error occurred")]
    Unknown,
}

// And app-specific job data
#[derive(Deserialize)]
struct MyJobData {
    my_property: String,
    my_other_property: String,
}

// And app-specific job result
#[derive(Serialize)]
struct MyJobResult {
    result: u32,
}

// Async job handler function
async fn handle_job(client: Client, data: MyJobData) -> Result<MyJobResult, MyError> {
   Ok(MyJobResult { result: 42 })
}

// Example use with async function
let job = client
    .job_worker()
    .with_job_type("my-job-type")
    .with_auto_handler(handle_job)
    .run()
    .await?;

// Use with closure
let job = client
    .job_worker()
    .with_job_type("my-job-type")
    .with_auto_handler(|client: Client, my_job_data: MyJobData| {
        future::ok::<_, MyError>(MyJobResult { result: 42 })
    })
    .run()
    .await?;

pub fn with_fetch_variables(self, fetch_variables: Vec<String>) -> Self[src]

Set the list of variables to fetch as the job variables.

By default all visible variables at the time of activation for the scope of the job will be returned.

pub async fn run(self) -> Result<()>[src]

Start the worker as a future. To stop the worker, simply drop the future.

Trait Implementations

impl Debug for JobWorkerBuilder[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T> Instrument for T[src]

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

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

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

type Error = Infallible

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<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]