Skip to main content

Envelope wrapper/unwrap for kpn-dsh-mqtt-envelopes

Project description

kpn-dsh-mqtt-envelope

Installation:

pip install kpn-dsh-mqtt-envelope

Usage:

...
# Import dsh_envelope
import dsh_envelope
...
# Deserialize the mqtt message from kafka consumer
(topic, message, tenant, publisher, publishertype, retain, qos, tracing) = dsh_envelope.unwrap(key, value)

# Serialize the mqtt fields into kafka producer
(key, value) = dsh_envelope.wrap(topic, message, tenant, publisher, publishertype, retain, qos, tracing)

where type(key) and type(value) are bytes as serialized/deserialized by DSH mqtt kafka bridge.

Example:

For a kafka-python consumer:

from kafka import KafkaConsumer, KafkaProducer

# Initiate consumer
consumer = KafkaConsumer(...)
# Subscribe to a stream with regex-pattern for <streamname>
consumer.subscribe(pattern='^stream\\.<streamname>\\.[^.]*')

for msg in consumer:
    (topic, message, tenant, publisher, publishertype, retain, qos, tracing) = dsh_envelope.unwrap(key, value)

will return serialized values of the fields:

topic: str
    mqtt topic suffix that the message is published to
message: bytes
    payload in bytes
tenant: str
    name of the tenant message is published from
publisher: str
    name of the publisher
publishertype: str
    type of the publisher
retain: bool
    if the message should be retained
    thus will be available in latest value store and through http-protocol-adapter
qos: int
    quality of service for mqtt
tracing: dict
    tracing span context in a python dictionary

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

kpn-dsh-mqtt-envelope-0.2.3.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file kpn-dsh-mqtt-envelope-0.2.3.tar.gz.

File metadata

  • Download URL: kpn-dsh-mqtt-envelope-0.2.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for kpn-dsh-mqtt-envelope-0.2.3.tar.gz
Algorithm Hash digest
SHA256 99663ae1d729dd31b72c1dca4d4a9988df37bb3df642b53a25dd2846648f4b0a
MD5 7f5e622a3cfd6a9cd4bba02680c049a7
BLAKE2b-256 c0c15040d89a284f5feed8f7bf4386c3959c1081c019fc57130417993ef40167

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page