operaton-external-task-client-python3 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- operaton_external_task_client_python3-1.0.0/LICENSE +201 -0
- operaton_external_task_client_python3-1.0.0/PKG-INFO +258 -0
- operaton_external_task_client_python3-1.0.0/README.md +234 -0
- operaton_external_task_client_python3-1.0.0/examples/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/examples/bpmn_error_example.py +75 -0
- operaton_external_task_client_python3-1.0.0/examples/correlate_message.py +11 -0
- operaton_external_task_client_python3-1.0.0/examples/event_subprocess_example.py +50 -0
- operaton_external_task_client_python3-1.0.0/examples/examples_auth_basic/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/examples/examples_auth_basic/fetch_and_execute.py +31 -0
- operaton_external_task_client_python3-1.0.0/examples/examples_auth_basic/get_process_instance.py +12 -0
- operaton_external_task_client_python3-1.0.0/examples/examples_auth_basic/start_process.py +15 -0
- operaton_external_task_client_python3-1.0.0/examples/examples_auth_basic/task_handler_example.py +44 -0
- operaton_external_task_client_python3-1.0.0/examples/fetch_and_execute.py +30 -0
- operaton_external_task_client_python3-1.0.0/examples/get_process_instance.py +12 -0
- operaton_external_task_client_python3-1.0.0/examples/retry_task_example.py +58 -0
- operaton_external_task_client_python3-1.0.0/examples/start_process.py +14 -0
- operaton_external_task_client_python3-1.0.0/examples/task_handler_example.py +44 -0
- operaton_external_task_client_python3-1.0.0/examples/tasks_example.py +36 -0
- operaton_external_task_client_python3-1.0.0/operaton/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/async_external_task_client.py +171 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/engine_client.py +180 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/external_task_client.py +166 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_async_external_task_client.py +128 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_async_external_task_client_auth.py +42 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_async_external_task_client_bearer.py +43 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_engine_client.py +228 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_engine_client_auth.py +231 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_engine_client_bearer.py +237 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_external_task_client.py +17 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_external_task_client_auth.py +19 -0
- operaton_external_task_client_python3-1.0.0/operaton/client/tests/test_external_task_client_bearer.py +24 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/async_external_task_executor.py +91 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/async_external_task_worker.py +181 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/external_task.py +173 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/external_task_executor.py +88 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/external_task_worker.py +92 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/tests/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/tests/test_async_external_task_executor.py +139 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/tests/test_async_external_task_worker.py +129 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/tests/test_external_task.py +106 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/tests/test_external_task_executor.py +200 -0
- operaton_external_task_client_python3-1.0.0/operaton/external_task/tests/test_external_task_worker.py +147 -0
- operaton_external_task_client_python3-1.0.0/operaton/process_definition/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/process_definition/process_definition_client.py +123 -0
- operaton_external_task_client_python3-1.0.0/operaton/process_definition/tests/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/process_definition/tests/test_process_definition_client.py +181 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/auth_basic.py +28 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/auth_bearer.py +28 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/log_utils.py +31 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/response_utils.py +35 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/tests/test_auth_basic.py +30 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/tests/test_auth_bearer.py +27 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/tests/test_response_utils.py +43 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/tests/test_utils.py +21 -0
- operaton_external_task_client_python3-1.0.0/operaton/utils/utils.py +14 -0
- operaton_external_task_client_python3-1.0.0/operaton/variables/__init__.py +0 -0
- operaton_external_task_client_python3-1.0.0/operaton/variables/properties.py +27 -0
- operaton_external_task_client_python3-1.0.0/operaton/variables/tests/test_properties.py +20 -0
- operaton_external_task_client_python3-1.0.0/operaton/variables/tests/test_variables.py +60 -0
- operaton_external_task_client_python3-1.0.0/operaton/variables/variables.py +45 -0
- operaton_external_task_client_python3-1.0.0/operaton_external_task_client_python3.egg-info/PKG-INFO +258 -0
- operaton_external_task_client_python3-1.0.0/operaton_external_task_client_python3.egg-info/SOURCES.txt +131 -0
- operaton_external_task_client_python3-1.0.0/operaton_external_task_client_python3.egg-info/dependency_links.txt +1 -0
- operaton_external_task_client_python3-1.0.0/operaton_external_task_client_python3.egg-info/requires.txt +1 -0
- operaton_external_task_client_python3-1.0.0/operaton_external_task_client_python3.egg-info/top_level.txt +6 -0
- operaton_external_task_client_python3-1.0.0/pyproject.toml +44 -0
- operaton_external_task_client_python3-1.0.0/setup.cfg +4 -0
- operaton_external_task_client_python3-1.0.0/setup.py +2 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: operaton_external_task_client_python3
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: External Task Client for Operaton BPM engine. Its based on the camunda-external-task-client-python3 and has been adapted to Operaton.
|
|
5
|
+
Author-email: Deserve Labs <devteam@deserve.com>
|
|
6
|
+
Maintainer: DLR terrabyte team
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/DLR-terrabyte/operaton-external-task-client-python3
|
|
9
|
+
Project-URL: Issues, https://github.com/DLR-terrabyte/operaton-external-task-client-python3/issues
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Requires-Python: >=3.7
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: requests>=2.24.0
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
> External Task Client for Operaton BPM engine.
|
|
26
|
+
> Its based on the [camunda-external-task-client-python3](https://github.com/camunda-community-hub/camunda-external-task-client-python3) and has been adapted to Operaton.
|
|
27
|
+
|
|
28
|
+
# operaton-external-task-client-python3
|
|
29
|
+
|
|
30
|
+
This repository contains Operaton External Task Client written in Python3.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Implement your [BPMN Service Task](https://docs.operaton.org/docs/documentation/user-guide/process-engine/external-tasks) in Python3.
|
|
34
|
+
|
|
35
|
+
> Python >= 3.7 is required
|
|
36
|
+
|
|
37
|
+
## Installing
|
|
38
|
+
Add following line to `requirements.txt` of your Python project.
|
|
39
|
+
```
|
|
40
|
+
git+https://github.com/trustfactors/operaton-external-task-client-python3.git/#egg=operaton-external-task-client-python3
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or use pip to install as shown below:
|
|
44
|
+
```
|
|
45
|
+
pip install operaton-external-task-client-python3
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Running Operaton with Docker
|
|
49
|
+
To run the examples provided in [examples](./examples) folder, you need to have Operaton running locally or somewhere.
|
|
50
|
+
|
|
51
|
+
To run Operaton locally with Postgres DB as backend, you can use [docker-compose.yml](./docker-compose.yml) file.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
$> docker-compose -f docker-compose.yml up
|
|
55
|
+
```
|
|
56
|
+
### Auth Basic Examples
|
|
57
|
+
|
|
58
|
+
> [!WARNING]
|
|
59
|
+
> This section needs to be refactored into a working example with Operaton.
|
|
60
|
+
|
|
61
|
+
To run the examples with Auth Basic provided in [examples/examples_auth_basic](./examples/examples_auth_basic) folder, you need to have Operaton with AuthBasic, running locally or somewhere.
|
|
62
|
+
|
|
63
|
+
To run Operaton with AuthBasic locally with Postgres DB as backend, you can use [docker-compose-auth.yml](./docker-compose-auth.yml) file.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
$> docker-compose -f docker-compose-auth.yml up
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
1. Make sure to have [Operaton](https://github.com/operaton/operaton/releases) running.
|
|
72
|
+
2. Create a simple process model with an External Service Task and define the topic as 'topicName'.
|
|
73
|
+
3. Deploy the process to the Operaton BPM engine.
|
|
74
|
+
4. In your Python code:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import time
|
|
78
|
+
from operaton.external_task.external_task import ExternalTask, TaskResult
|
|
79
|
+
from operaton.external_task.external_task_worker import ExternalTaskWorker
|
|
80
|
+
|
|
81
|
+
# configuration for the Client
|
|
82
|
+
default_config = {
|
|
83
|
+
"maxTasks": 1,
|
|
84
|
+
"lockDuration": 10000,
|
|
85
|
+
"asyncResponseTimeout": 5000,
|
|
86
|
+
"retries": 3,
|
|
87
|
+
"retryTimeout": 5000,
|
|
88
|
+
"sleepSeconds": 30
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
def handle_task(task: ExternalTask) -> TaskResult:
|
|
92
|
+
"""
|
|
93
|
+
This task handler you need to implement with your business logic.
|
|
94
|
+
After completion of business logic call either task.complete() or task.failure() or task.bpmn_error()
|
|
95
|
+
to report status of task to Operaton
|
|
96
|
+
"""
|
|
97
|
+
# add your business logic here
|
|
98
|
+
# ...
|
|
99
|
+
|
|
100
|
+
# mark task either complete/failure/bpmnError based on outcome of your business logic
|
|
101
|
+
failure, bpmn_error = random_true(), random_true() # this code simulate random failure
|
|
102
|
+
if failure:
|
|
103
|
+
# this marks task as failed in Operaton
|
|
104
|
+
return task.failure(error_message="task failed", error_details="failed task details",
|
|
105
|
+
max_retries=3, retry_timeout=5000)
|
|
106
|
+
elif bpmn_error:
|
|
107
|
+
return task.bpmn_error(error_code="BPMN_ERROR_CODE", error_message="BPMN Error occurred",
|
|
108
|
+
variables={"var1": "value1", "success": False})
|
|
109
|
+
|
|
110
|
+
# pass any output variables you may want to send to Operaton as dictionary to complete()
|
|
111
|
+
return task.complete({"var1": 1, "var2": "value"})
|
|
112
|
+
|
|
113
|
+
def random_true():
|
|
114
|
+
current_milli_time = int(round(time.time() * 1000))
|
|
115
|
+
return current_milli_time % 2 == 0
|
|
116
|
+
|
|
117
|
+
if __name__ == '__main__':
|
|
118
|
+
ExternalTaskWorker(worker_id="1", config=default_config).subscribe("topicName", handle_task)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## About External Tasks
|
|
122
|
+
|
|
123
|
+
External Tasks are service tasks whose execution differs particularly from the execution of other service tasks (e.g. Human Tasks).
|
|
124
|
+
The execution works in a way that units of work are polled from the engine before being completed.
|
|
125
|
+
|
|
126
|
+
**operaton-external-task-client-python** allows you to create easily such client in Python3.
|
|
127
|
+
|
|
128
|
+
## Features
|
|
129
|
+
|
|
130
|
+
### Start process
|
|
131
|
+
Operaton provides functionality to start a process instance for a given process definition.
|
|
132
|
+
|
|
133
|
+
To start a process instance, we can use `start_process()` from [engine_client.py](./operaton/client/engine_client.py#L24)
|
|
134
|
+
|
|
135
|
+
You can find a usage example [here](./examples/start_process.py).
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
client = EngineClient()
|
|
139
|
+
resp_json = client.start_process(process_key="PARALLEL_STEPS_EXAMPLE", variables={"intVar": "1", "strVar": "hello"},
|
|
140
|
+
tenant_id="6172cdf0-7b32-4460-9da0-ded5107aa977", business_key=str(uuid.uuid1()))
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Fetch and Lock
|
|
144
|
+
|
|
145
|
+
`ExternalTaskWorker(worker_id="1").subscribe("topicName", handle_task)` starts long polling of the Operaton engine for external tasks.
|
|
146
|
+
|
|
147
|
+
* Polling tasks from the engine works by performing a fetch & lock operation of tasks that have subscriptions. It then calls the handler function passed to `subscribe()` function. i.e. `handle_task` in above example.
|
|
148
|
+
* Long Polling is done periodically based on the `asyncResponseTimeout` configuration. Read more about [Long Polling](https://docs.operaton.org/docs/documentation/user-guide/process-engine/external-tasks#long-polling-to-fetch-and-lock-external-tasks).
|
|
149
|
+
|
|
150
|
+
### Complete
|
|
151
|
+
```python
|
|
152
|
+
from operaton.external_task.external_task import ExternalTask, TaskResult
|
|
153
|
+
from operaton.external_task.external_task_worker import ExternalTaskWorker
|
|
154
|
+
def handle_task(task: ExternalTask) -> TaskResult:
|
|
155
|
+
# add your business logic here
|
|
156
|
+
|
|
157
|
+
# Complete the task
|
|
158
|
+
# pass any output variables you may want to send to Operaton as dictionary to complete()
|
|
159
|
+
return task.complete({"var1": 1, "var2": "value"})
|
|
160
|
+
|
|
161
|
+
ExternalTaskWorker(worker_id="1").subscribe("topicName", handle_task)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Handle Failure
|
|
165
|
+
```python
|
|
166
|
+
from operaton.external_task.external_task import ExternalTask, TaskResult
|
|
167
|
+
from operaton.external_task.external_task_worker import ExternalTaskWorker
|
|
168
|
+
def handle_task(task: ExternalTask) -> TaskResult:
|
|
169
|
+
# add your business logic here
|
|
170
|
+
|
|
171
|
+
# Handle task Failure
|
|
172
|
+
return task.failure(error_message="task failed", error_details="failed task details",
|
|
173
|
+
max_retries=3, retry_timeout=5000)
|
|
174
|
+
# This client/worker uses max_retries if no retries are previously set in the task
|
|
175
|
+
# if retries are previously set then it just decrements that count by one before reporting failure to Operaton
|
|
176
|
+
# when retries are zero, Operaton creates an incident which then manually needs to be looked into on Operaton Cockpit
|
|
177
|
+
|
|
178
|
+
ExternalTaskWorker(worker_id="1").subscribe("topicName", handle_task)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Handle BPMN Error
|
|
182
|
+
```python
|
|
183
|
+
from operaton.external_task.external_task import ExternalTask, TaskResult
|
|
184
|
+
from operaton.external_task.external_task_worker import ExternalTaskWorker
|
|
185
|
+
def handle_task(task: ExternalTask) -> TaskResult:
|
|
186
|
+
# add your business logic here
|
|
187
|
+
|
|
188
|
+
# Handle a BPMN Failure
|
|
189
|
+
return task.bpmn_error(error_code="BPMN_ERROR", error_message="BPMN error occurred")
|
|
190
|
+
|
|
191
|
+
ExternalTaskWorker(worker_id="1" ).subscribe("topicName", handle_task)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Access Process Variables
|
|
195
|
+
```python
|
|
196
|
+
from operaton.external_task.external_task import ExternalTask, TaskResult
|
|
197
|
+
from operaton.external_task.external_task_worker import ExternalTaskWorker
|
|
198
|
+
def handle_task(task: ExternalTask) -> TaskResult:
|
|
199
|
+
# add your business logic here
|
|
200
|
+
# get the process variable 'score'
|
|
201
|
+
score = task.get_variable("score")
|
|
202
|
+
if int(score) >= 100:
|
|
203
|
+
return task.complete(...)
|
|
204
|
+
else:
|
|
205
|
+
return task.failure(...)
|
|
206
|
+
|
|
207
|
+
ExternalTaskWorker().subscribe("topicName", handle_task)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### [Correlate message](https://docs.operaton.org/docs/documentation/reference/bpmn20/events/message-events/)
|
|
211
|
+
Operaton provides functionality to send a message event to a running process instance.
|
|
212
|
+
|
|
213
|
+
You can read more about the message events here: https://docs.operaton.org/docs/documentation/reference/bpmn20/events/message-events/
|
|
214
|
+
|
|
215
|
+
In our to send a message event to a process instance, a new function called `correlate_message()` is added to [engine_client.py](./operaton/client/engine_client.py#L60)
|
|
216
|
+
|
|
217
|
+
We can correlate the message by:
|
|
218
|
+
- process_instance_id
|
|
219
|
+
- tenant_id
|
|
220
|
+
- business_key
|
|
221
|
+
- process_variables
|
|
222
|
+
|
|
223
|
+
You can find a usage example [here](./examples/correlate_message.py).
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
client = EngineClient()
|
|
227
|
+
resp_json = client.correlate_message("CANCEL_MESSAGE", business_key="b4a6f392-12ab-11eb-80ef-acde48001122")
|
|
228
|
+
```
|
|
229
|
+
## AuthBasic Usage
|
|
230
|
+
|
|
231
|
+
To create an EngineClient with AuthBasic simple
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
client = EngineClient(config={"auth_basic": {"username": "demo", "password": "demo"}})
|
|
235
|
+
resp_json = client.start_process(process_key="PARALLEL_STEPS_EXAMPLE", variables={"intVar": "1", "strVar": "hello"},
|
|
236
|
+
tenant_id="6172cdf0-7b32-4460-9da0-ded5107aa977", business_key=str(uuid.uuid1()))
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
To create an ExternalTaskWorker with AuthBasic simple
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from operaton.external_task.external_task import ExternalTask, TaskResult
|
|
243
|
+
from operaton.external_task.external_task_worker import ExternalTaskWorker
|
|
244
|
+
|
|
245
|
+
config = {"auth_basic": {"username": "demo", "password": "demo"}}
|
|
246
|
+
|
|
247
|
+
def handle_task(task: ExternalTask) -> TaskResult:
|
|
248
|
+
# add your business logic here
|
|
249
|
+
|
|
250
|
+
# Complete the task
|
|
251
|
+
# pass any output variables you may want to send to Operaton as dictionary to complete()
|
|
252
|
+
return task.complete({"var1": 1, "var2": "value"})
|
|
253
|
+
|
|
254
|
+
ExternalTaskWorker(worker_id="1", config=config).subscribe("topicName", handle_task)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
The source files in this repository are made available under the [Apache License Version 2.0](./LICENSE).
|