Struct zeebe::Client [−][src]
pub struct Client { /* fields omitted */ }
Expand description
Client used to communicate with Zeebe.
Implementations
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::with_endpoints(endpoints));
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),
auth: None,
})?;
Future that resolves when the auth interceptor is initialized.
Obtains the current topology of the cluster the gateway is part of.
Examples
let client = zeebe::Client::new();
let topology = client.topology().send().await?;
Deploys one or more processes to Zeebe. Note that this is an atomic call, i.e. either all processes are deployed, or none of them are.
Examples
let client = zeebe::Client::new();
let process = client
.deploy_process()
.with_resource_file("path/to/process.bpmn")
.send()
.await?;
Creates and starts an instance of the specified process.
The process definition to use to create the instance can be specified
either using its unique key (as returned by deploy_process
), or using the
BPMN process ID and a version. Pass -1 as the version to use the latest
deployed version.
Note that only processes with none start events can be started through this command.
Examples
use serde_json::json;
let client = zeebe::Client::new();
let process_instance = client
.create_process_instance()
.with_bpmn_process_id("example-process")
.with_latest_version()
.with_variables(json!({"myData": 31243}))
.send()
.await?;
Similar to create_process_instance
, creates and starts an instance of
the specified process_
Unlike create_process_instance
, the response is returned when the
process_is completed.
Note that only processes with none start events can be started through this command.
Examples
use serde_json::json;
let client = zeebe::Client::new();
let process_instance_with_result = client
.create_process_instance_with_result()
.with_bpmn_process_id("example-process")
.with_latest_version()
.with_variables(json!({"myData": 31243}))
.send()
.await?;
Cancels a running process instance.
Examples
let client = zeebe::Client::new();
// process instance key, e.g. from a `CreateProcessInstanceResponse`.
let process_instance_key = 2251799813687287;
let canceled = client
.cancel_process_instance()
.with_process_instance_key(process_instance_key)
.send()
.await?;
Updates all the variables of a particular scope (e.g. process instance, flow element instance) from the given JSON document.
Examples
use serde_json::json;
let client = zeebe::Client::new();
// process instance key, e.g. from a `CreateProcessInstanceResponse`.
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?;
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;
}
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?;
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?;
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?;
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 process 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?;
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?;
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
impl !UnwindSafe for Client
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Wrap the input message T
in a tonic::Request
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more