Адаптер для BPMN-движка Camunda
Project description
camunda-adapter
Пакет предоставляет адаптер к платформе Camunda для приложений на Python.
Установка
$ pip install camunda-adapter
Подключение и настройка
См. тестовое приложение src/testapp.
apps.py:
Инстанцируется Config с параметрами конфигурации, затем инстанцируется Adapter.
При необходимости работы с внешними задачами, регистрируются обработчики задач путем подписки на соответствующие топики задач.
from django.apps import AppConfig as AppConfigBase
from camunda_adapter.adapters import Adapter
from camunda_adapter.config import Config
class AppConfig(AppConfigBase):
name = __package__
def ready(self):
self._setup_bpmn()
def _setup_bpmn(self):
from testapp import core
from . import services
core.config = Config()
core.adapter = Adapter(core.config)
for topic, handler in (
(services.topic1, services.topic_handler1),
(services.topic2, services.topic_handler2),
(services.topicN, services.topic_handlerN),
):
core.adapter.register_topic_handler(topic, handler)
services.py:
from camunda_adapter.domain import model as camunda
topic1 = camunda.Topic(name='topic-1')
def topic_handler1(task: camunda.ExternalTask, adapter: Adapter):
...
topic2 = camunda.Topic(name='topic-2')
def topic_handler2(task: camunda.ExternalTask, adapter: Adapter):
...
topicN = camunda.Topic(name='topic-N')
def topic_handlerN(task: camunda.ExternalTask, adapter: Adapter):
...
Примеры непосредственного обращения к адаптеру:
Отправка сообщения:
message = model.Message(
messageName='DeclarationReceived',
businessKey=f'attestation-declaration-{declaration.id}',
processVariables={
name: model.Variable(value=value)
for name, value in declaration.dict(include={'id'}).items()
}
)
message_results: List[model.MessageResult] = list(adapter.message(message))
Получение списка доступных задач:
adapter.get_external_tasks(definition=definition)
Выполнение доступных задач:
adapter.process_external_tasks()
Тестирование
Для запуска тестов используется tox с плагином tox-docker, запускающим контейнер Camunda.
Установка tox:
$ pip install tox tox-docker
Запуск тестов из директории пакета:
$ tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
camunda-adapter-1.1.0.tar.gz
(28.3 kB
view hashes)
Built Distribution
Close
Hashes for camunda_adapter-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6642f3434d92b57551ae03c6fdfab11a2afd78ed01969977f0b82a080a049d5 |
|
MD5 | ce1e85a51a6a3e6f976a8b44a851b728 |
|
BLAKE2b-256 | 6f89b9567705c6697e21171ade270ebb09fc10dbc9f217ceeefa82d0427c621d |