Skip to main content

SDK of Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge

Project description

Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge

Install

pip install diaspora-event-sdk

Use kafka-python

Claim Topic Ownership

from diaspora_event_sdk import Client as GlobusClient
c = GlobusClient()
topic = f"topic-of-{c.subject_openid}" # or any unclaimed topic
print(c.acl_add(topic))
print(c.acl_list())

Create Topic

from diaspora_event_sdk import KafkaAdmin, NewTopic 
admin = KafkaAdmin()
res = admin.create_topics(new_topics=[NewTopic(name=topic, num_partitions=2, replication_factor=2)])
print(res)

Start Producer

from diaspora_event_sdk import Producer
future = producer.send(
    topic, {'message': 'Synchronous message from Diaspora SDK'})
result = future.get(timeout=10)
print(result)

Start Consumer

from diaspora_event_sdk import Consumer  # Kafka producer
consumer = Consumer(topic)
for msg in consumer:
    print(msg)

Delete Topic

from diaspora_event_sdk import KafkaAdmin
admin = KafkaAdmin()
res = admin.delete_topics(topics=[topic])
print(res)

Release Topic Ownership

from diaspora_event_sdk import Client as GlobusClient
c = GlobusClient()
topic = f"topic-of-{c.subject_openid}" # or any topic you claimed
print(c.acl_remove(topic))
print(c.acl_list())

Use other Kafka libraries

from diaspora_event_sdk import Client as GlobusClient
c = GlobusClient()
c.retrieve_or_create_key()

For SASL/SCRAM authentication, use username and secret_key as authentication credential; For AWS_MSK_IAM authentication, use access_key and secret_key as authentication credential.

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

diaspora-event-sdk-0.0.3.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

diaspora_event_sdk-0.0.3-py3-none-any.whl (15.8 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