Skip to main content

A simple python library for interacting with the ARGO Messaging Service

Project description

argo-ams-library

Jenkins Build Status

A simple python library for interacting with the ARGO Messaging Service.

The Messaging Services is implemented as a Publish/Subscribe Service. Instead of focusing on a single Messaging API specification for handling the logic of publishing/subscribing to the broker network the API focuses on creating nodes of Publishers and Subscribers as a Service.

In the Publish/Subscribe paradigm, Publishers are users/systems that can send messages to named-channels called Topics. Subscribers are users/systems that create Subscriptions to specific topics and receive messages.

You may find more information about the ARGO Messaging Service documentation

Library installation

Library is tested and should work with Python versions 2.6, 2.7, 3.4 and 3.6 running on CentOS 6 and CentOS 7 releases.

RPM packages are prepared for both CentOS releases and you may find it and download it from ARGO Repository. PyPI packages are prepared as well.

RPM production packages:

http://rpm-repo.argo.grnet.gr/ARGO/prod/centos6/ http://rpm-repo.argo.grnet.gr/ARGO/prod/centos7/

RPM devel packages:

http://rpm-repo.argo.grnet.gr/ARGO/devel/centos6/ http://rpm-repo.argo.grnet.gr/ARGO/devel/centos7/

PyPI package:

https://pypi.org/project/argo-ams-library/

Authentication

The AMS library uses a valid AMS token to execute requests against the AMS cluster. This token can be provided with 2 ways:

  • Obtain a valid ams token and then use it when initializing the ams object.
from argo_ams_library import ArgoMessagingService
ams = ArgoMessagingService(endpoint="ams_endpoint", project="ams_project", token="your_ams_token")
  • Use a valid certificate
from argo_ams_library import ArgoMessagingService
ams = ArgoMessagingService(endpoint="ams_endpoint", project="ams_project", cert="/path/to/cert", key="/path/to/cert/key")

The library will use the provided certificate to access the corresponding ams token through the ARGO Authentication Service and then set the ams object's token field with the retrieved token.

Examples

In the folder examples, you may find examples of using the library:

  • for publishing messages (examples/publish.py)
  • for consuming messages in pull mode (examples/consume-pull.py)
  • retry feature for publish/consume methods (examples/retry.py)

Publish messages

This example explains how to publish messages in a topic with the use of the library. Topics are resources that can hold messages. Publishers (users/systems) can create topics on demand and name them (Usually with names that make sense and express the class of messages delivered in the topic). A topic name must be scoped to a project.

You may find more information about Topics in the ARGO Messaging Service documentation

publish.py  --host=[the FQDN of AMS Service] 
--token=[the user token] 
--project=[the name of your project registered in AMS Service] 
--topic=[the topic to publish your messages]

Consume messages in pull mode

This example explains how to consume messages from a predefined subscription with the use of the library. A subscription is a named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application. A subscription name must be scoped to a project. In pull delivery, your subscriber application initiates requests to the Pub/Sub server to retrieve messages. When you create a subscription, the system establishes a sync point. That is, your subscriber is guaranteed to receive any message published after this point. Messages published before the sync point may not be delivered.

You may find more information about Subscriptions in the ARGO Messaging Service documentation

consume-pull.py  --host=[the FQDN of AMS Service] 
--token=[the user token] 
--project=[the name of your project registered in AMS Service] 
--topic=[the topic from where the messages are delivered ] 
--subscription=[the subscription name to pull the messages]  
--nummsgs=[the num of messages to consume]

Retry

Library has self-implemented HTTP request retry ability to seamlesssly interact with the ARGO Messaging service. Specifically, requests will be retried in case of:

  • timeouts from AMS (HTTP 408) or load balancer (HTTP 408 and 504)
  • load balancer HTTP 502, 503
  • connection related problems in the lower network layers

It has two modes: static sleep and backoff. Examples are given in the in examples/retry.py.

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

argo-ams-library-0.5.5.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argo_ams_library-0.5.5-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file argo-ams-library-0.5.5.tar.gz.

File metadata

  • Download URL: argo-ams-library-0.5.5.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

File hashes

Hashes for argo-ams-library-0.5.5.tar.gz
Algorithm Hash digest
SHA256 a1a492ff2eb7ff679f6de924120f3395de2605d1df93fb403c02e143db427a15
MD5 b29b36fc7aead20a0bfaa428ab3f244c
BLAKE2b-256 e80f2bf9bea3866313f0f321d40130d30f325d21285dd6091fb7fa9e9926c6b4

See more details on using hashes here.

File details

Details for the file argo_ams_library-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: argo_ams_library-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

File hashes

Hashes for argo_ams_library-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bdc44b0470255cb334ab82357771b6f6dd7b7350996675c4ddc65004b75ea035
MD5 00697d1832b84cd62008bcded645018e
BLAKE2b-256 02a7c49cda5c3985c03993cb3fe0f987d615068a2d2ae070f446c4c1be8ae29d

See more details on using hashes here.

Supported by

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