Skip to main content

Diaspora Logger

Diaspora Logger is a library for logging events to the Diaspora Streams (Kafka) cluster. The producer and consumer connections to Diaspora Streams are authenticated with Globus Auth. Follow the steps below to set up a DiasporaLogger instance for producing events.

Install

pip install diaspora_logger

Setup

  1. Generate Globus Auth Tokens: Run credentials.py to generate a Globus Auth access token and a refresh token.

    from diaspora_logger import request_token_workflow
    
    request_token_workflow()
    

    Here's an example run:

    Please visit the following URL to authorize the application: <Globus Auth /authorize endpoint>
    Paste the authorization code here: <authorization-code>
    ================================
    Subject claim:     <subject-claim>
    Principal name:    <subject-username>
    Access token:      <access-token>
    Refresh token:     <refresh-token>
    Py clients:        export DIASPORA_REFRESH=<refresh-token>
    Java clients:      Connection properties are saved to <subject-username>.properties.
    ================================
    

    Note that the <access-token> is good for 48 hours once generated. The <refresh-token> expires after six months of inactivity but is good forever if used. The token owner can revoke the refresh token; see Globus Auth documentation for details.

    To generate <subject-username>.properties for Java clients, call request_token_workflow with the optional argument save_for_java=True

  2. Register Topics: Use the public ACL endpoint to claim topics.

    A topic only needs to be claimed once, skip this step if you have a topic claimed previously.

    The request form takes three inputs:

    • Subject Claim: paste in the <subject-claim> retrieved above.
    • Access Token: paste in the <access-token> retrieved above.
    • Topic Name: a string consists of letters, numbers, and underscores. A topic name cannot start with an underscore.

    Once the form is submitted, this endpoint also generates an equivalent GET request with the form filled for conveniently claiming another topic through the web interface and an equivalent CURL POST request for using CLI tools to interact with the public ACL endpoint.

    If the access token expires, the access token and the subject claim do not match, or the topic has ACL rules associated already (i.e., claimed by other users), the request will fail.

    If a topic is claimed by an user, different refresh token (if ever requested) would also work for this topic.

  3. Export Credential: Instead of hard-coding the refresh token to your code repository, export it to your environment for using it. You could also put the token in a read-only file in the production environment.

    export DIASPORA_REFRESH=<Globus-Auth-refresh-token>
    
  4. Run a Producer: Set the topic variable to your producer topic, then call run_producer_example() to start the producer.

    from diaspora_logger.examples import run_producer_example
    
    topic = "<claimed-topic>"
    run_producer_example(topic)
    

    Inside this example, a DiasporaLogger instance is created, and all method calls to this instance will be directed to its _producer object, a KafkaProducer instance of the kafka-python library. In other words, you can use DiasporaLogger exactly the same as a KafkaProducer.

  5. Run a Consumer: Set the topic and group_id variables to your consumer topic and group ID respectively, then call run_consumer_example(topic, group_id) to start the consumer.

    from diaspora_logger.examples import run_consumer_example
    
    topic = '<consumer-topic>'
    groupid = "<some-group-id-of-your-choice>"
    run_consumer_example(topic, groupid)
    

Communication Flows

A

Metadata

Release files for diaspora-logger 0.0.8

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

Source distribution (sdist)

Source distribution for diaspora-logger 0.0.8
File Size Uploaded
diaspora_logger-0.0.8.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diaspora-logger 0.0.8
File Interpreter ABI Platform
diaspora_logger-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / diaspora_logger-0.0.8.tar.gz

Download URL diaspora_logger-0.0.8.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
245eb4fb127770f8d0edacfb615afe3c3b7275d5fff01d717a42674fe61ee33c
BLAKE2b-256 checksum
How to use checksums
d79b3beb31f8a9619e04fec03bb261ff06b51d2828871762b775e12727a2718c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / diaspora_logger-0.0.8-py3-none-any.whl

Download URL diaspora_logger-0.0.8-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b362fed1e1f7d39d83823f186f0d7ebedf8ecc22a67568427db1c27ef778915d
BLAKE2b-256 checksum
How to use checksums
8df54ffc09b9670693f9854363397078e292d90997e1a18091006649549f24c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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