Skip to main content

Адаптер для 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


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 details)

Uploaded Source

Built Distribution

camunda_adapter-1.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file camunda-adapter-1.1.0.tar.gz.

File metadata

  • Download URL: camunda-adapter-1.1.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for camunda-adapter-1.1.0.tar.gz
Algorithm Hash digest
SHA256 65e31f2e8139bff3564f14a6f5be2046475b98a76c7de4a71d4343cd3044e3c2
MD5 173320330bb7b03bb12adde002d4d86a
BLAKE2b-256 d7a67d0dcc0df07bc66a99f31ba5b23c4279f36b0b83f07947b2b366c6b39aae

See more details on using hashes here.

File details

Details for the file camunda_adapter-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for camunda_adapter-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6642f3434d92b57551ae03c6fdfab11a2afd78ed01969977f0b82a080a049d5
MD5 ce1e85a51a6a3e6f976a8b44a851b728
BLAKE2b-256 6f89b9567705c6697e21171ade270ebb09fc10dbc9f217ceeefa82d0427c621d

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