Skip to main content

Ensign driver, SDK, and helpers for Python

Project description

PyEnsign

PyEnsign is the official Python SDK for Ensign, a distributed event store and stream-processing platform. This library allows you to interact with the Ensign API directly from Python in order to create publishers and subscribers.

Installation

pip install pyensign

Usage

Create a client from a client ID and client secret. If not provided, these will be obtained from the ENSIGN_CLIENT_ID and ENSIGN_CLIENT_SECRET variables.

from pyensign.ensign import Ensign

client = Ensign(client_id=<your client ID>, client_secret=<your client secret>)

The Event class can be used to create events from the raw data and mimetype.

from pyensign.events import Event

event = Event(b'{"temp": 72, "units": "fahrenheit"}', "APPLICATION_JSON")

Publish events to a topic. This function accepts anything that is iterable. Errors are concatenated into a list and returned after all the events have been published.

errors = await client.publish("weather", event)

Subcribe to a topic or list of topics.

async for event in client.subscribe("weather"):
    print("Received event: {}".format(event))

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

pyensign-0.1a1.tar.gz (17.4 kB view hashes)

Uploaded Source

Built Distribution

pyensign-0.1a1-py3-none-any.whl (20.1 kB view hashes)

Uploaded Python 3

Supported by

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