[−][src]Struct zeebe::JobWorkerBuilder
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]
T: Fn(Client, Job) -> R + Send + Sync + 'static,
R: Future<Output = ()> + Send + 'static,
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]
F: Fn(Client, J) -> R + Send + Sync + 'static,
R: Future<Output = Result<T, E>> + Send + 'static,
E: Error,
T: Serialize,
J: DeserializeOwned,
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
Auto Trait Implementations
impl !RefUnwindSafe for JobWorkerBuilder
impl Send for JobWorkerBuilder
impl Sync for JobWorkerBuilder
impl Unpin for JobWorkerBuilder
impl !UnwindSafe for JobWorkerBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoRequest<T> for T
[src]
fn into_request(self) -> Request<T>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,