Package: diaspora-logger
Diaspora LoggerDiaspora 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 aDiasporaLoggerinstance for producing events.Installpipinstalldiaspora_loggerSetupGenerate Globus Auth Tokens:Runcredentials.pyto generate a Globus Auth access token and a refresh token.fromdiaspora_loggerimportrequest_token_workflowrequest_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>.propertiesfor Java clients, callrequest_token_workflowwith the optional argumentsave_for_java=TrueRegister Topics:Use thepublic ACL endpointto 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.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.exportDIASPORA_REFRESH=<Globus-Auth-refresh-token>Run a Producer:Set thetopicvariable to your producer topic, then callrun_producer_example()to start the producer.fromdiaspora_logger.examplesimportrun_producer_exampletopic="<claimed-topic>"run_producer_example(topic)Inside this example, aDiasporaLoggerinstance is created, and all method calls to this instance will be directed to its_producerobject, aKafkaProducerinstance of the kafka-python library. In other words, you can useDiasporaLoggerexactly the same as aKafkaProducer.Run a Consumer:Set thetopicandgroup_idvariables to your consumer topic and group ID respectively, then callrun_consumer_example(topic, group_id)to start the consumer.fromdiaspora_logger.examplesimportrun_consumer_exampletopic='<consumer-topic>'groupid="<some-group-id-of-your-choice>"run_consumer_example(topic,groupid)Communication Flows