Skip to main content

Zeebe client api

Project description

Coverage Status Test pyzeebe Integration test pyzeebe GitHub issues GitHub pull requests GitHub closed pull requests GitHub tag (latest by date) PyPI - Python Version PyPI

Pyzeebe

pyzeebe is a python grpc client for Zeebe.

Zeebe version support:

Pyzeebe version Tested Zeebe versions
2.x.x 0.23, 0.24
1.x.x 0.23, 0.24

Getting Started

To install:

pip install pyzeebe

Usage

Worker

The ZeebeWorker class uses threading to get and run jobs.

from pyzeebe import ZeebeWorker, Job


def on_error(exception: Exception, job: Job):
    """
    on_error will be called when the task fails
    """ 
    print(exception)
    job.set_error_status(f"Failed to handle job {job}. Error: {str(exception)}")



worker = ZeebeWorker(hostname="<zeebe_host>", port=26500) # Create a zeebe worker

@worker.task(task_type="example", exception_handler=on_error)
def example_task(input: str):
    return {"output": f"Hello world, {input}!"}


worker.work() # Now every time that a task with type example is called example_task will be called

Stop a worker:

zeebe_worker.work() # Worker will begin working
zeebe_worker.stop() # Stops worker after all running jobs have been completed 

Client

from pyzeebe import ZeebeClient

# Create a zeebe client
zeebe_client = ZeebeClient(hostname="localhost", port=26500)

# Run a workflow
workflow_instance_key = zeebe_client.run_workflow(bpmn_process_id="My zeebe workflow", variables={})

# Run a workflow and receive the result
workflow_result = zeebe_client.run_workflow_with_result(bpmn_process_id="My zeebe workflow",
                                                        timeout=10000)  # Will wait 10000 milliseconds (10 seconds)

# Deploy a bpmn workflow definition
zeebe_client.deploy_workflow("workflow.bpmn")

# Cancel a running workflow
zeebe_client.cancel_workflow_instance(workflow_instance_key=12345)

# Publish message
zeebe_client.publish_message(name="message_name", correlation_key="some_id")

Tests

Use the package manager pip to install pyzeebe

pytest tests/unit

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

We use the MIT license, see LICENSE.md for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyzeebe-2.0.1.tar.gz (31.5 kB view hashes)

Uploaded Source

Built Distribution

pyzeebe-2.0.1-py3-none-any.whl (45.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page