Skip to main content

A Python library for NATS server connection, publishing, creation, and validation of events.

Project description

dverse-nats-helper

dverse-nats-helper is a Python library for dealing nats server connection, publishng, creation and validation of the events

Installation

Use the package manager pip to install dverse-nats-helper.

pip install dverse-nats-helper

Usage

from dverse_nats_helper.event_builder import build_event
from dverse_nats_helper.nats_connection import publish_event, connect_nats

# Establishes a connection to the NATS server.
await connect_nats("nats://nats:4222")

# Constructs an event message conforming to a predefined schema.
# The object must implement a to_event_object() method.
system = { "platform": "example", "service": "example_svc", "event_type": "created"},
new_event = build_event(product,actor={"actor_id": str(seller.id), "username": seller.username}, system)

# Publishes an event to the specified NATS subject
# after validating the data against a predefined schema.
await publish_event("example.subject", new_event)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT License

Copyright (c) 2024 fuas-dverse

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

dverse_nats_helper-0.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dverse_nats_helper-0.2.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file dverse_nats_helper-0.2.0.tar.gz.

File metadata

  • Download URL: dverse_nats_helper-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dverse_nats_helper-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3f496ebeede57d566f1c32da5b7aecf3ceb24d693fc5ee84e050e4c2d65ebe09
MD5 a655d79a50925dac4ce0fe5729eda082
BLAKE2b-256 d9d287eba17b1f385eb59fbe56a40a5b081cffaa88149bec65cd98fa1cf7362d

See more details on using hashes here.

File details

Details for the file dverse_nats_helper-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dverse_nats_helper-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ade270d152caeb7d1910478e4a4b8eea6cdc0879dc9f4e0e74c6afa590bbcf5
MD5 face553aa3c8e71e8d15206a1ec2adf3
BLAKE2b-256 fd98324e5f2d7cb5357c05256e2f9737e18ce4e36c5e1bbaa432f02e59a578d3

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