Explicit-Kafka
Набор компонентов для интеграции explicit с kafka.
Содержит реализацию адаптера обмена сообщениями через Kafka.
Пример использования
Настройка адаптера
# persons/core/apps.py
from django.apps.config import AppConfig as AppConfigBase
class AppConfig(AppConfigBase):
name = __package__
def _setup_adapter(self):
from explicit.kafka.adapters.messaging import Adapter
from explicit.kafka.adapters.messaging import PublishConfig
from explicit.kafka.adapters.messaging import SubscribeConfig
from persons import core
# конфигурация адаптера
adapter_base_config = {'bootstrap.servers': 'kafka:9092'}
publish_config = PublishConfig(adapter_base_config)
subscribe_config = SubscribeConfig(adapter_base_config | {'group.id': f'edu.persons'})
adapter = Adapter(subscribe_config=subscribe_config, publish_config=publish_config)
core.adapter = adapter
def ready(self):
self._setup_adapter()
Отправка сообщений
# persons/core/persons/services/handlers/events.py
def on_person_created(
event: 'PersonCreated',
messaging_adapter: 'AbstractMessagingAdapter'
):
messaging_adapter.publish('edu.persons.person', event.dump())
Подписка на сообщения
# education/entrypoints/eventconsumer.py
def bootstrap():
import json
from education.core import adapter
from education.core import bus
from education.core.persons.domain.events import PersonCreated
TOPIC_EVENTS = {
'edu.persons.person': PersonCreated,
}
for message in adapter.subscribe(*TOPIC_EVENTS):
for message in adapter.subscribe(*TOPIC_EVENTS):
event = TOPIC_EVENTS[message.topic()](
**json.loads(message.value())
)
bus.handle(event)
bootstrap()
Запуск тестов
$ tox
Metadata
Release files for explicit-kafka 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| explicit_kafka-1.1.0.tar.gz | 7.8 kB | Without provenance | Details for explicit_kafka-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| explicit_kafka-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for explicit_kafka-1.1.0-py3-none-any.whl |
Total release size: 15.6 kB
Release files / explicit_kafka-1.1.0.tar.gz
| Download URL | explicit_kafka-1.1.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c865bbbda60d5f02400d9d3e9fcdb77e8ce9eac3eff1f8d0bfc4207152f8f0f4
|
|
BLAKE2b-256 checksum How to use checksums |
ec1c193c6b2562b880f07717da5ec7dfeae2faa2e943dee3da86085099a2949d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.11.1 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.1 tqdm/4.66.5 importlib-metadata/7.1.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.4
|
Release files / explicit_kafka-1.1.0-py3-none-any.whl
| Download URL | explicit_kafka-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0fe278ef80ff6358c1d25e7a27e046ec7f19347755cd8f183042ea73a368b98
|
|
BLAKE2b-256 checksum How to use checksums |
1e086c0cc041a551420fbebf82e99eea039961d2ec421807d54a1f930efc0e17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.11.1 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.1 tqdm/4.66.5 importlib-metadata/7.1.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.4
|
Security for explicit-kafka 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.