Struct zeebe::Client [−][src]
Client used to communicate with Zeebe.
Implementations
impl Client
[src]
pub fn new() -> Self
[src]
Create a new client with default config.
pub fn from_config(config: ClientConfig) -> Result<Self>
[src]
Build a new Zeebe client from a given configuration.
Examples
use zeebe::{Client, ClientConfig}; let endpoints = vec!["http://0.0.0.0:26500".to_string()]; let client = Client::from_config(ClientConfig { endpoints, tls: None })?;
with TLS (see the ClientTlsConfig docs for configuration):
use zeebe::{Client, ClientConfig}; use tonic::transport::ClientTlsConfig; let endpoints = vec!["http://0.0.0.0:26500".to_string()]; let tls = ClientTlsConfig::new(); let client = Client::from_config(ClientConfig { endpoints, tls: Some(tls), })?;
pub fn topology(&self) -> TopologyBuilder
[src]
Obtains the current topology of the cluster the gateway is part of.
Examples
let client = zeebe::Client::new(); let topology = client.topology().send().await?;
pub fn deploy_workflow(&self) -> DeployWorkflowBuilder
[src]
Deploys one or more workflows to Zeebe. Note that this is an atomic call, i.e. either all workflows are deployed, or none of them are.
Examples
let client = zeebe::Client::new(); let workflow = client .deploy_workflow() .with_resource_file("path/to/process.bpmn") .send() .await?;
pub fn create_workflow_instance(&self) -> CreateWorkflowInstanceBuilder
[src]
Creates and starts an instance of the specified workflow.
The workflow definition to use to create the instance can be specified
either using its unique key (as returned by deploy_workflow
), or using the
BPMN process ID and a version. Pass -1 as the version to use the latest
deployed version.
Note that only workflows with none start events can be started through this command.
Examples
use serde_json::json; let client = zeebe::Client::new(); let workflow_instance = client .create_workflow_instance() .with_bpmn_process_id("example-process") .with_latest_version() .with_variables(json!({"myData": 31243})) .send() .await?;
pub fn create_workflow_instance_with_result(
&self
) -> CreateWorkflowInstanceWithResultBuilder
[src]
&self
) -> CreateWorkflowInstanceWithResultBuilder
Similar to create_workflow_instance
, creates and starts an instance of
the specified workflow.
Unlike create_workflow_instance
, the response is returned when the
workflow is completed.
Note that only workflows with none start events can be started through this command.
Examples
use serde_json::json; let client = zeebe::Client::new(); let workflow_instance_with_result = client .create_workflow_instance_with_result() .with_bpmn_process_id("example-process") .with_latest_version() .with_variables(json!({"myData": 31243})) .send() .await?;
pub fn cancel_workflow_instance(&self) -> CancelWorkflowInstanceBuilder
[src]
Cancels a running workflow instance.
Examples
let client = zeebe::Client::new(); // workflow instance key, e.g. from a `CreateWorkflowInstanceResponse`. let workflow_instance_key = 2251799813687287; let canceled = client .cancel_workflow_instance() .with_workflow_instance_key(workflow_instance_key) .send() .await?;
pub fn set_variables(&self) -> SetVariablesBuilder
[src]
Updates all the variables of a particular scope (e.g. workflow instance, flow element instance) from the given JSON document.
Examples
use serde_json::json; let client = zeebe::Client::new(); // workflow instance key, e.g. from a `CreateWorkflowInstanceResponse`. let element_instance_key = 2251799813687287; let set_variables = client .set_variables() .with_element_instance_key(element_instance_key) .with_variables(json!({"myNewKey": "myValue"})) .send() .await?;
pub fn job_worker(&self) -> JobWorkerBuilder
[src]
Create a new job worker builder.
Examples
use zeebe::{Client, Job}; let client = Client::new(); client .job_worker() .with_job_type("my-service") .with_handler(handle_job) .run() .await?; // job handler function async fn handle_job(client: Client, job: Job) { // processing work... let _ = client.complete_job().with_job_key(job.key()).send().await; }
pub fn complete_job(&self) -> CompleteJobBuilder
[src]
Completes a job with the given payload, which allows completing the associated service task.
Examples
let client = zeebe::Client::new(); // typically obtained from `job.key()`; let job_key = 2251799813687287; let completed_job = client .complete_job() .with_job_key(job_key) .send() .await?;
pub fn fail_job(&self) -> FailJobBuilder
[src]
Marks the job as failed.
If the retries
argument is positive, then the job will be immediately
activatable again, and a worker could try again to process it. If it is zero
or negative however, an incident will be raised, tagged with the given
error_message
, and the job will not be activatable until the incident is
resolved.
Examples
let client = zeebe::Client::new(); // typically obtained from `job.key()`; let job_key = 2251799813687287; let failed_job = client .fail_job() .with_job_key(job_key) .with_error_message("something went wrong.") .send() .await?;
pub fn update_job_retries(&self) -> UpdateJobRetriesBuilder
[src]
Updates the number of retries a job has left.
This is mostly useful for jobs that have run out of retries, should the underlying problem be solved.
Examples
let client = zeebe::Client::new(); // typically obtained from `job.key()`; let job_key = 2251799813687287; let updated = client .update_job_retries() .with_job_key(job_key) .with_retries(2) .send() .await?;
pub fn throw_error(&self) -> ThrowErrorBuilder
[src]
Throw an error to indicate that a business error has occurred while processing the job.
The error is identified by an error code and is handled by an error catch event in the workflow with the same error code.
Examples
let client = zeebe::Client::new(); // typically obtained from `job.key()`; let job_key = 2251799813687287; let error = client .throw_error() .with_job_key(job_key) .with_error_message("something went wrong") .with_error_code("E2505") .send() .await?;
pub fn publish_message(&self) -> PublishMessageBuilder
[src]
Publishes a single message. Messages are published to specific partitions computed from their correlation keys.
Examples
use serde_json::json; let client = zeebe::Client::new(); let message = client .publish_message() .with_name("myEvent") .with_variables(json!({"someKey": "someValue"})) .send() .await?;
pub fn resolve_incident(&self) -> ResolveIncidentBuilder
[src]
Resolves a given incident.
This simply marks the incident as resolved; most likely a call to
update_job_retries
will be necessary to actually resolve the problem,
followed by this call.
Examples
let client = zeebe::Client::new(); let incident_key = 2251799813687287; let resolved = client .resolve_incident() .with_incident_key(incident_key) .send() .await?;
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
[src]
impl !Send for Client
[src]
impl !Sync for Client
[src]
impl Unpin for Client
[src]
impl !UnwindSafe for Client
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub 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]
pub fn into_request(self) -> Request<T>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut 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.
pub 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.
pub 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>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,