Skip to main content
GitHub tag (latest by date) PyPI - Module Version PyPI - License PyPI - Downloads Quay - Build

This provides a library called thoth-messaging used in project Thoth. It is a basic module to encapsule all messaging (here it is Kafka via Faust) primitives.

Type Hinting With MyPy

This module uses pydantic for type hinting and enforcing a regular schema in messaging. If you are using mypy to check your code please add the following to your mypy configuration file:

[mypy]
plugins = pydantic.mypy

If you are creating an instance of a pydantic model in your own module you should directly use the MessageContents class within the associate message file. Using foo_bar_message.model will only type hint for BaseMessageContents.

Development and Testing

For development and testing it is very useful to have a local instance of Kafka running on your machine

We provide a docker-compose file to get you up and running quickly with a basic Kafka server; this file is based on Single Zookeeper/Multiple Kafka.

In order to start Zookeeper as well as the Kafka Servers simply run $ podman-compose up or $ docker-compose up, choose the appropriate option based on the system which you are using.

Once you have Kafka up and running you should be ready to begin coding your own messaging producers and consumers. The interface between Kafka and Python is handled by a library called Confluent Kafka. Faust’s documentation will be extremely helpful to you when you are developing your own applications. If you would like examples of producers and consumers from Team Thoth, look at the following two repositories, investigator and package-update.

You may find it useful to use console producers and consumers while testing your, to create one simply attach a bash shell to one of your Kafka Servers by running: $ podman exec -it messaging_kafka1_1 bash, your container names should be the same as given here, if not, run $ podman ps and choose the correct container. These containers have all Kafka binaries in appropriate places so you can simply run $ kafka-console-consumer, $ kafka-console-producer, or any other kafka command that you may find useful.

example:

kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning

You can test sending a message via the CLI using a file as -

example:

pipenv shell
python cli.py --message-file messages_to_be_sent.json

Note Data is not persistent. Once pods are deleted so is the data associated with them.

Pitfalls

Some schemas in this library are defined as Dict[str, Any]. This usually does not accurately reflect the actual schema required. These schemas can be purposefully vague because they are defined elsewhere and importing them from the requisite libraries couples thoth-messaging version too closely to other components in the best case, and introduces circular dependencies in the worst case. In short, thoth-messaging is naive and can only enforce schemas which it has defined.

Release files for thoth-messaging 0.16.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thoth-messaging 0.16.2
File Size Uploaded
thoth-messaging-0.16.2.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thoth-messaging 0.16.2
File Interpreter ABI Platform
thoth_messaging-0.16.2-py3-none-any.whl Python 3 none any Details

Total release size: 65.9 kB

Release files / thoth-messaging-0.16.2.tar.gz

Download URL thoth-messaging-0.16.2.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6a814ed282dd914c22ca54069c6869ede2405ecccfc02f0eb349661a0f3cc279
BLAKE2b-256 checksum
How to use checksums
a50b163054d34aef4c43af4b25f5fd81fa3d0f8726803e7c7c9fc2f7665b59da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

Release files / thoth_messaging-0.16.2-py3-none-any.whl

Download URL thoth_messaging-0.16.2-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
113a7874c1e2f50bd1dfec0063d24a4f0a3ce0fadde612db26bb5d358e381cd8
BLAKE2b-256 checksum
How to use checksums
22211f6b6fa571b569a050f95152ced472f332b2b80d1fac85148e628eb196c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

Release history Release notifications | RSS feed

This release

0.16.2 This release

2 release files

0.16.0

2 release files

0.14.3

2 release files

0.14.2

2 release files

0.14.0

2 release files

0.13.0

1 release file

0.12.0

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.13

2 release files

0.7.12

2 release files

0.7.9

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.0

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

1 release file

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page