camunda-adapter


Namecamunda-adapter JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://stash.bars-open.ru/projects/M3/repos/camunda-adapter
SummaryАдаптер для BPMN-движка Camunda
upload_time2023-09-04 02:56:58
maintainer
docs_urlNone
authorBARS Group
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # camunda-adapter

Пакет предоставляет адаптер к платформе Camunda для приложений на Python.

## Установка

```bash

  $ pip install camunda-adapter

```


## Подключение и настройка


См. тестовое приложение src/testapp.


### apps.py:

Инстанцируется Config с параметрами конфигурации, затем инстанцируется Adapter.

При необходимости работы с внешними задачами, регистрируются обработчики задач путем подписки на соответствующие топики задач.



```python

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:


```python

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):
    ...

```

### Примеры непосредственного обращения к адаптеру:

Отправка сообщения:

```python

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

```

Получение списка доступных задач:

```python

adapter.get_external_tasks(definition=definition)

```

Выполнение доступных задач:

```python

adapter.process_external_tasks()

```


## Тестирование

Для запуска тестов используется tox с плагином tox-docker, запускающим контейнер Camunda.

Установка tox:

```bash

$ pip install tox tox-docker

```

Запуск тестов из директории пакета:

```bash

$ tox

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://stash.bars-open.ru/projects/M3/repos/camunda-adapter",
    "name": "camunda-adapter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "BARS Group",
    "author_email": "bars@bars-open.ru",
    "download_url": "https://files.pythonhosted.org/packages/d7/a6/7d0dcc0df07bc66a99f31ba5b23c4279f36b0b83f07947b2b366c6b39aae/camunda-adapter-1.1.0.tar.gz",
    "platform": null,
    "description": "# camunda-adapter\n\n\u041f\u0430\u043a\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043a \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 Camunda \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 Python.\n\n## \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\n\n```bash\n\n  $ pip install camunda-adapter\n\n```\n\n\n## \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\n\n\n\u0421\u043c. \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 src/testapp.\n\n\n### apps.py:\n\n\u0418\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f Config \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f Adapter.\n\n\u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430\u0434\u0430\u0447 \u043f\u0443\u0442\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u043e\u043f\u0438\u043a\u0438 \u0437\u0430\u0434\u0430\u0447.\n\n\n\n```python\n\nfrom django.apps import AppConfig as AppConfigBase\n\nfrom camunda_adapter.adapters import Adapter\nfrom camunda_adapter.config import Config\n\n\nclass AppConfig(AppConfigBase):\n\n    name = __package__\n\n    def ready(self):\n        self._setup_bpmn()\n\n    def _setup_bpmn(self):\n        from testapp import core\n\n        from . import services\n\n        core.config = Config()\n        core.adapter = Adapter(core.config)\n\n        for topic, handler in (\n            (services.topic1, services.topic_handler1),\n            (services.topic2, services.topic_handler2),\n            (services.topicN, services.topic_handlerN),\n\n        ):\n            core.adapter.register_topic_handler(topic, handler)\n\n```\n\n\n### services.py:\n\n\n```python\n\nfrom camunda_adapter.domain import model as camunda\n\n\ntopic1 = camunda.Topic(name='topic-1')\ndef topic_handler1(task: camunda.ExternalTask, adapter: Adapter):\n    ...\n\n\ntopic2 = camunda.Topic(name='topic-2')\ndef topic_handler2(task: camunda.ExternalTask, adapter: Adapter):\n    ...\n\n\ntopicN = camunda.Topic(name='topic-N')\ndef topic_handlerN(task: camunda.ExternalTask, adapter: Adapter):\n    ...\n\n```\n\n### \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0443:\n\n\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:\n\n```python\n\nmessage = model.Message(\n    messageName='DeclarationReceived',\n    businessKey=f'attestation-declaration-{declaration.id}',\n    processVariables={\n        name: model.Variable(value=value)\n        for name, value in declaration.dict(include={'id'}).items()\n    }\n)\nmessage_results: List[model.MessageResult] = list(adapter.message(message))\n\n```\n\n\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447:\n\n```python\n\nadapter.get_external_tasks(definition=definition)\n\n```\n\n\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447:\n\n```python\n\nadapter.process_external_tasks()\n\n```\n\n\n## \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\n\n\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f tox \u0441 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u043c tox-docker, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 Camunda.\n\n\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 tox:\n\n```bash\n\n$ pip install tox tox-docker\n\n```\n\n\u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u0430:\n\n```bash\n\n$ tox\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f BPMN-\u0434\u0432\u0438\u0436\u043a\u0430 Camunda",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://stash.bars-open.ru/projects/M3/repos/camunda-adapter"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f89b9567705c6697e21171ade270ebb09fc10dbc9f217ceeefa82d0427c621d",
                "md5": "ce1e85a51a6a3e6f976a8b44a851b728",
                "sha256": "a6642f3434d92b57551ae03c6fdfab11a2afd78ed01969977f0b82a080a049d5"
            },
            "downloads": -1,
            "filename": "camunda_adapter-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce1e85a51a6a3e6f976a8b44a851b728",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13495,
            "upload_time": "2023-09-04T02:56:56",
            "upload_time_iso_8601": "2023-09-04T02:56:56.587910Z",
            "url": "https://files.pythonhosted.org/packages/6f/89/b9567705c6697e21171ade270ebb09fc10dbc9f217ceeefa82d0427c621d/camunda_adapter-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7a67d0dcc0df07bc66a99f31ba5b23c4279f36b0b83f07947b2b366c6b39aae",
                "md5": "173320330bb7b03bb12adde002d4d86a",
                "sha256": "65e31f2e8139bff3564f14a6f5be2046475b98a76c7de4a71d4343cd3044e3c2"
            },
            "downloads": -1,
            "filename": "camunda-adapter-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "173320330bb7b03bb12adde002d4d86a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 28267,
            "upload_time": "2023-09-04T02:56:58",
            "upload_time_iso_8601": "2023-09-04T02:56:58.554401Z",
            "url": "https://files.pythonhosted.org/packages/d7/a6/7d0dcc0df07bc66a99f31ba5b23c4279f36b0b83f07947b2b366c6b39aae/camunda-adapter-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-04 02:56:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "camunda-adapter"
}
        
Elapsed time: 0.17395s