[][src]Crate zeebe

A rust client for defining, orchestrating, and monitoring business processes across microservices using Zeebe.

What is Zeebe?

Zeebe is a workflow engine for microservices orchestration. Zeebe ensures that, once started, flows are always carried out fully, retrying steps in case of failures. Along the way, Zeebe maintains a complete audit log so that the progress of flows can be monitored. Zeebe is fault tolerant and scales seamlessly to handle growing transaction volumes.

Example

use serde_json::json;
use zeebe::{Client, Job};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a zeebe client
    let client = Client::default();

    // Deploy a workflow
    client
        .deploy_workflow()
        .with_resource_file("examples/workflows/order-process.bpmn")
        .send()
        .await?;

    // Create a new workflow instance
    client
        .create_workflow_instance()
        .with_bpmn_process_id("order-process")
        .with_latest_version()
        .with_variables(json!({"orderId": 31243}))
        .send()
        .await?;

    // Process a job type within the workflow
    client
        .job_worker()
        .with_job_type("payment-service")
        .with_handler(handle_job)
        .run()
        .await?;

    Ok(())
}

async fn handle_job(client: Client, job: Job) {
    /// your job processing logic...

    let _ = client.complete_job().with_job_key(job.key()).send().await;
}

Or with job success and failure reported for you automatically from your function result:

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 })
}

// You can run a worker from your function with results auto reported
let job = client
    .job_worker()
    .with_job_type("my-job-type")
    .with_auto_handler(handle_job)
    .run()
    .await?;

// OR you can run a closure and have the results auto reported
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?;

Structs

BrokerInfo

Zeebe broker info

CancelWorkflowInstanceBuilder

Cancels a running workflow instance.

CancelWorkflowInstanceResponse

Canceled workflow instance data.

Client

Client used to communicate with Zeebe.

ClientConfig

Config for establishing zeebe client.

CompleteJobBuilder

Configuration to complete a job

CompleteJobResponse

Completed job instance data.

CreateWorkflowInstanceBuilder

Creates and starts an instance of the specified workflow.

CreateWorkflowInstanceResponse

Created workflow instance data.

CreateWorkflowInstanceWithResultBuilder

Creates and starts an instance of the specified workflow with result.

CreateWorkflowInstanceWithResultResponse

Created workflow instance with result data.

DeployWorkflowBuilder

Deploys one or more workflows to Zeebe.

DeployWorkflowResponse

Deployed workflow data.

FailJobBuilder

Configuration to fail a job

FailJobResponse

Failed job instance data.

Job

An activate Zeebe job that is ready to be worked on by a worker.

JobWorkerBuilder

Configuration for an asynchronous worker process.

Partition

Zeebe partition.

PublishMessageBuilder

Configuration to publish a message.

PublishMessageResponse

The publish message data.

ResolveIncidentBuilder

Configuration to resolve an incident.

ResolveIncidentResponse

The resolve incident data.

SetVariablesBuilder

Updates all the variables of a particular scope (e.g. workflow instance, flow element instance) from the given JSON document.

SetVariablesResponse

Set variables data.

ThrowErrorBuilder

Configuration to throw an error in the context of a job.

ThrowErrorResponse

Throw error response data.

TopologyBuilder

Request to obtain the current topology of the cluster the gateway is part of.

TopologyResponse

The current topology of the cluster

UpdateJobRetriesBuilder

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.

UpdateJobRetriesResponse

Update job retries data.

WorkflowMetadata

Metadata information about a workflow.

Enums

Error

The error type which is returned from zeebe processing failures.

WorkflowResourceType

The format of the uploaded workflows.

Type Definitions

Result

The result type returned by zeebe methods.