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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for diaspora_event_sdk-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0da430be292338d155d39993730f5c5a0533d23f87f3b55bb71c6bb08e29be7 |
|
MD5 | 752077993bfcdc221b71a1d3d349a8cb |
|
BLAKE2b-256 | 0ea815f300a2bbbd8efb40b55dbf16b112d8633a55cf1c8a02781a56fbd029e9 |