zeebe-grpc


Namezeebe-grpc JSON
Version 8.4.0 PyPI version JSON
download
home_pagehttps://gitlab.com/stephane.ludwig/zeebe_python_grpc
Summaryzeebe Python gRPC Gateway
upload_time2024-01-16 15:40:51
maintainer
docs_urlNone
authorStéphane Ludwig
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # zeebe Python gRPC gateway files

This package contains two gRPC Gateway Files needed to build a zeebe-client or a zeebe-worker (https://zeebe.io/)
with Python.

Both files were generated following the instructions on this (now outdated) blog post:
https://zeebe.io/blog/2018/11/grpc-generating-a-zeebe-python-client/

## How to install and use this package?

```bash
pip install zeebe-grpc
```
```python
import json
import logging
import grpc
from zeebe_grpc import gateway_pb2, gateway_pb2_grpc

with grpc.insecure_channel("localhost:26500") as channel:
    stub = gateway_pb2_grpc.GatewayStub(channel)

    # print the topology of the zeebe cluster
    topology = stub.Topology(gateway_pb2.TopologyRequest())
    print(topology)

    # deploy a process definition
    with open("bpmn/echo.bpmn", "rb") as process_definition_file:
        process_definition = process_definition_file.read()
        process = gateway_pb2.ProcessRequestObject(
            name="echo.bpmn",
            definition=process_definition
        )
    stub.DeployProcess(
        gateway_pb2.DeployProcessRequest(
            processes=[process]
        )
    )

    # start a process instance
    variables = {
        "message": "This is a Message"
    }
    stub.CreateProcessInstance(
        gateway_pb2.CreateProcessInstanceRequest(
            bpmnProcessId="ECHO",
            version=-1,
            variables=json.dumps(variables)
        )
    )

    # start a worker
    activate_jobs_response = stub.ActivateJobs(
        gateway_pb2.ActivateJobsRequest(
            type="echo",
            worker="Python worker",
            timeout=60000,
            maxJobsToActivate=32
        )
    )
    for response in activate_jobs_response:
        for job in response.jobs:
            try:
                print(job.variables)
                stub.CompleteJob(gateway_pb2.CompleteJobRequest(jobKey=job.key, variables=json.dumps({})))
                logging.info("Job Completed")
            except Exception as e:
                stub.FailJob(gateway_pb2.FailJobRequest(jobKey=job.key))
                logging.info(f"Job Failed {e}")
```

## How to (re)build the Python gRPC?

```bash
wget https://raw.githubusercontent.com/zeebe-io/zeebe/0.21.1/gateway-protocol/src/main/proto/gateway.proto -O ./zeebe_grpc/gateway.proto

python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./zeebe_grpc/gateway.proto
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/stephane.ludwig/zeebe_python_grpc",
    "name": "zeebe-grpc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "St\u00e9phane Ludwig",
    "author_email": "gitlab@stephane-ludwig.net",
    "download_url": "https://files.pythonhosted.org/packages/13/1f/80f036abc558518779c0f206f0efaa0ed270578de5b61011d719c121e7e9/zeebe_grpc-8.4.0.tar.gz",
    "platform": null,
    "description": "# zeebe Python gRPC gateway files\n\nThis package contains two gRPC Gateway Files needed to build a zeebe-client or a zeebe-worker (https://zeebe.io/)\nwith Python.\n\nBoth files were generated following the instructions on this (now outdated) blog post:\nhttps://zeebe.io/blog/2018/11/grpc-generating-a-zeebe-python-client/\n\n## How to install and use this package?\n\n```bash\npip install zeebe-grpc\n```\n```python\nimport json\nimport logging\nimport grpc\nfrom zeebe_grpc import gateway_pb2, gateway_pb2_grpc\n\nwith grpc.insecure_channel(\"localhost:26500\") as channel:\n    stub = gateway_pb2_grpc.GatewayStub(channel)\n\n    # print the topology of the zeebe cluster\n    topology = stub.Topology(gateway_pb2.TopologyRequest())\n    print(topology)\n\n    # deploy a process definition\n    with open(\"bpmn/echo.bpmn\", \"rb\") as process_definition_file:\n        process_definition = process_definition_file.read()\n        process = gateway_pb2.ProcessRequestObject(\n            name=\"echo.bpmn\",\n            definition=process_definition\n        )\n    stub.DeployProcess(\n        gateway_pb2.DeployProcessRequest(\n            processes=[process]\n        )\n    )\n\n    # start a process instance\n    variables = {\n        \"message\": \"This is a Message\"\n    }\n    stub.CreateProcessInstance(\n        gateway_pb2.CreateProcessInstanceRequest(\n            bpmnProcessId=\"ECHO\",\n            version=-1,\n            variables=json.dumps(variables)\n        )\n    )\n\n    # start a worker\n    activate_jobs_response = stub.ActivateJobs(\n        gateway_pb2.ActivateJobsRequest(\n            type=\"echo\",\n            worker=\"Python worker\",\n            timeout=60000,\n            maxJobsToActivate=32\n        )\n    )\n    for response in activate_jobs_response:\n        for job in response.jobs:\n            try:\n                print(job.variables)\n                stub.CompleteJob(gateway_pb2.CompleteJobRequest(jobKey=job.key, variables=json.dumps({})))\n                logging.info(\"Job Completed\")\n            except Exception as e:\n                stub.FailJob(gateway_pb2.FailJobRequest(jobKey=job.key))\n                logging.info(f\"Job Failed {e}\")\n```\n\n## How to (re)build the Python gRPC?\n\n```bash\nwget https://raw.githubusercontent.com/zeebe-io/zeebe/0.21.1/gateway-protocol/src/main/proto/gateway.proto -O ./zeebe_grpc/gateway.proto\n\npython -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./zeebe_grpc/gateway.proto\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "zeebe Python gRPC Gateway",
    "version": "8.4.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/stephane.ludwig/zeebe_python_grpc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9eea1b421c44da0415b2f66363447883ca9f60bfe8d55cf21910bfa9948eb146",
                "md5": "95ba1110de971f5a3f0e1127d4420312",
                "sha256": "d83e2f76a3eafa10298200b0c1c4f37ee9eca84902a973516c6293d88bd16a23"
            },
            "downloads": -1,
            "filename": "zeebe_grpc-8.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "95ba1110de971f5a3f0e1127d4420312",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13393,
            "upload_time": "2024-01-16T15:40:49",
            "upload_time_iso_8601": "2024-01-16T15:40:49.857637Z",
            "url": "https://files.pythonhosted.org/packages/9e/ea/1b421c44da0415b2f66363447883ca9f60bfe8d55cf21910bfa9948eb146/zeebe_grpc-8.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "131f80f036abc558518779c0f206f0efaa0ed270578de5b61011d719c121e7e9",
                "md5": "b1442f25300ccb1fc4ed9b497100cd5f",
                "sha256": "ff84f11df4c519937d877a9b253b8b9e7492b5d1661f2dd7b9a62f0dc131ac7c"
            },
            "downloads": -1,
            "filename": "zeebe_grpc-8.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b1442f25300ccb1fc4ed9b497100cd5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13763,
            "upload_time": "2024-01-16T15:40:51",
            "upload_time_iso_8601": "2024-01-16T15:40:51.699622Z",
            "url": "https://files.pythonhosted.org/packages/13/1f/80f036abc558518779c0f206f0efaa0ed270578de5b61011d719c121e7e9/zeebe_grpc-8.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-16 15:40:51",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "stephane.ludwig",
    "gitlab_project": "zeebe_python_grpc",
    "lcname": "zeebe-grpc"
}
        
Elapsed time: 0.16618s