Skip to main content

Custom pyzeebe for lzgabel

Project description

Compatible with: Camunda Platform 8

Coverage Status Test pyzeebe Integration test pyzeebe

GitHub tag (latest by date) PyPI PyPI - Python Version

Documentation Status

Pyzeebe

pyzeebe is a python grpc client for Zeebe.

Zeebe version support:

Pyzeebe version Tested Zeebe versions
3.x.x 1.0.0
2.x.x 0.23, 0.24, 0.25, 0.26
1.x.x 0.23, 0.24

Getting Started

To install:

pip install pyzeebe

For full documentation please visit: https://pyzeebe.readthedocs.io/en/stable/

Usage

Worker

The ZeebeWorker class gets jobs from the gateway and runs them.

import asyncio

from pyzeebe import ZeebeWorker, Job, create_insecure_channel


channel = create_insecure_channel(hostname="localhost", port=26500) # Create grpc channel
worker = ZeebeWorker(channel) # Create a zeebe worker


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


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


@worker.task(task_type="example2", exception_handler=on_error)
async def another_example_task(name: str) -> dict: # Tasks can also be async
    return {"output": f"Hello world, {name} from async task!"}

loop = asyncio.get_running_loop()
loop.run_until_complete(worker.work()) # Now every time that a task with type `example` or `example2` is called, the corresponding function will be called

Stop a worker:

await zeebe_worker.stop() # Stops worker after all running jobs have been completed

Client

from pyzeebe import ZeebeClient, create_insecure_channel

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

# Run a Zeebe process instance
process_instance_key = await zeebe_client.run_process(bpmn_process_id="My zeebe process", variables={})

# Run a process and receive the result
process_instance_key, process_result = await zeebe_client.run_process_with_result(
    bpmn_process_id="My zeebe process",
    timeout=10000
)

# Deploy a BPMN process definition
await zeebe_client.deploy_process("process.bpmn")

# Cancel a running process
await zeebe_client.cancel_process_instance(process_instance_key=12345)

# Publish message
await 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.

In order to bump the current version run:

$ bump2version <part>

where part is the part that will be bumped (major/minor/patch/rc).

This will bump the version in all relevant files as well as create a git commit.

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-lzgabel-8.4.0.1.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

pyzeebe_lzgabel-8.4.0.1-py2.py3-none-any.whl (62.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyzeebe-lzgabel-8.4.0.1.tar.gz.

File metadata

  • Download URL: pyzeebe-lzgabel-8.4.0.1.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.2

File hashes

Hashes for pyzeebe-lzgabel-8.4.0.1.tar.gz
Algorithm Hash digest
SHA256 92765fc2fe2ca2549592082e7628477e3bfdcb7ce44703c19624d32cc860f1e1
MD5 9e00cfd4724f3105e76420eb43925dfc
BLAKE2b-256 2d72f7432aa78f0d384a06a4256035a3dc44f6f2b9c128cd817fa1d9e470fd2f

See more details on using hashes here.

File details

Details for the file pyzeebe_lzgabel-8.4.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyzeebe_lzgabel-8.4.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7a0ddd1771d12a7b6a4e8734d6f8b59a8e77e2dda3ab485c28acd3965379574f
MD5 49442cc1422db3f46ad82833fd4e2a9f
BLAKE2b-256 5a6f20e7307af32bec4a578305aa7fded1e94a6482a5fb40389ee2205541fa22

See more details on using hashes here.

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