|
1 | | -# Flowable External Worker Library for Python |
2 | | - |
| 1 | +# Flowable External Client Python |
3 | 2 |
|
4 | 3 | [License: |
5 | 4 | ](https://github.com/flowable/flowable-external-client-python/blob/main/LICENSE) |
6 | 5 |
|
7 | 6 |  |
8 | 7 |
|
9 | | -An _External Worker Task_ in BPMN or CMMN is a task where the custom logic of that task is executed externally to Flowable, i.e. on another server. |
10 | | -When the process or case engine arrives at such a task, it will create an **external job**, which is exposed over the REST API. |
11 | | -Through this REST API, the job can be acquired and locked. |
12 | | -Once locked, the custom logic is responsible for signalling over REST that the work is done and the process or case can continue. |
13 | | - |
14 | | -This project makes implementing such custom logic in Python easy by not having the worry about the low-level details of the REST API and focus on the actual custom business logic. |
15 | | -Integrations for other languages are available, too. |
16 | | - |
17 | | -## Authentication |
18 | | - |
19 | | -The different ways to authenticate are explained in the [documentation of the underlying requests HTTP library which is used to connect to Flowable](https://requests.readthedocs.io/en/latest/user/authentication/). |
20 | | -The `ExternalWorkerClient` accepts as a parameter `auth` an implementation of `requests.auth.AuthBase`. |
21 | | -There are default implementations for example for basic authentication e.g. `HTTPBasicAuth("admin", "test")`. |
22 | | -Flowable offers a bearer token implementation `FlowableCloudToken` which allows to specify an access token to the Flowable Cloud offering. |
23 | | - |
24 | | -## Installation |
25 | | - |
26 | | -To install the external worker library, execute the following command: |
27 | | - |
28 | | -``` |
29 | | -pip install flowable.external-worker-client |
30 | | -``` |
31 | | - |
32 | | -## Sample |
33 | | - |
34 | | -### Cloud |
35 | | - |
36 | | -The usage with Flowable Cloud is simpler, since everything is pre-configured. |
37 | | -However, it's required to either use the user credentials or to pre-configure a personal access token. |
38 | | - |
39 | | -```python |
40 | | -from flowable.external_worker_client import ExternalWorkerClient |
41 | | -from flowable.external_worker_client.cloud_token import FlowableCloudToken |
42 | | - |
43 | | -client = ExternalWorkerClient(auth=FlowableCloudToken("<personal-access-token>")) |
44 | | - |
45 | | -def my_callback(job, worker_result_builder): |
46 | | - print('Executed job: ' + job.id) |
47 | | - return worker_result_builder.success() |
48 | | - |
49 | | -subscription = client.subscribe('myTopic', my_callback) |
50 | | -``` |
51 | | - |
52 | | -### Local |
53 | | - |
54 | | -The following is an example how you can connect to a Flowable instance running at `http://localhost:8090` and process all messages retrieved on the topic `myTopic`: |
55 | | - |
56 | | -```python |
57 | | -from flowable.external_worker_client import ExternalWorkerClient |
58 | | -from requests.auth import HTTPBasicAuth |
59 | | - |
60 | | -client = ExternalWorkerClient('http://localhost:8090/flowable-work', auth=HTTPBasicAuth("admin", "test")) |
61 | | - |
62 | | -def my_callback(job, worker_result_builder): |
63 | | - print('Executed job: ' + job.id) |
64 | | - return worker_result_builder.success() |
65 | | - |
66 | | -subscription = client.subscribe('myTopic', my_callback) |
67 | | -``` |
| 8 | +This is a collection of multiple Flowable Python clients. |
| 9 | +Currently, the project consists out of: |
68 | 10 |
|
| 11 | +* [External Worker Client](./external-worker): A library to connect custom application code to Flowable with the external worker functionality |
| 12 | +* [Robocorp Client](./robocorp-client): A python module to execute Robocorp actions and tasks with the Flowable Robocorp task (based on the external worker). |
0 commit comments