Skip to main content

Really Simple Service Registry - Python Client

Project description

srsr

Really Simple Service Registry - Python Client

Description

This is the Python client for srsr.

Usage

Typical

from srsrpy import srsrpy

# Store the client object for the lifetime of the service
# If the client's address and port bindings are known, specify:
c = srsrpy.ServiceRegistryClient('http://server.address.com:8080', 'service_name', 'http://client.address.net:3333')

# Alternatively, omit the address and specify the client port only.
# The server will assume http scheme and try to deduce the client IP.
c = srsrpy.ServiceRegistryClient('http://server.address.com:8080', 'service_name', port='3333')

# Returns True if registered. After this point, a thread is active for heartbeats.
success = c.register()

# Carry on with the service duties. Heartbeats will be sent at the default interval.

# At teardown time, deregister
c.deregister()

Example shutdown using interrupt handler

import signal
svc_reg = ServiceRegistryClient('http://server_hostname', 'service_name', 'http://client_hostname')
success = svc_reg.register()

if success:
   prev_handler = signal.getsignal(signal.SIGINT)
   def handle_sigint(sig, frame):
        svc_reg.deregister()

        if prev_handler:
            prev_handler(sig, frame)
    signal.signal(signal.SIGINT, handle_sigint)

Further plans

  • Handle failed heartbeat, by stopping the thread.

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

srsrpy-0.2.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

srsrpy-0.2.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file srsrpy-0.2.1.tar.gz.

File metadata

  • Download URL: srsrpy-0.2.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for srsrpy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 55f53680d9c14871b2463d261e2053dd4a46f944f6ba64664e5af08e78af64cd
MD5 5cd86d1b588439935948b9cd1fddf3bf
BLAKE2b-256 b0f7e7b1d47cfc631e9f52b91c8f25bed2a51c171a2bf7db87c04209171bc18a

See more details on using hashes here.

File details

Details for the file srsrpy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: srsrpy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for srsrpy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 163b42d92543d920ab87b914b9447ba663633da59d88b2f2df9ad219b0e9266b
MD5 ae98c70af04f1bd3b1a585032e9c28d9
BLAKE2b-256 ce91ef00fda8310369f3c6eb76d5164c7bbe75a2c72d0c3e2ca9a2b68e48c45e

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