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()

Advanced Configuration

from srsrpy import srsrpy

# Configure custom heartbeat interval and error handling
def heartbeat_error_handler(error):
    print(f"Heartbeat failed: {error}")

c = srsrpy.ServiceRegistryClient(
    'http://server.address.com:8080',
    'service_name',
    'http://client.address.net:3333',
    heartbeat_interval=10,  # Custom heartbeat interval in seconds (default: 20)
    heartbeat_error_handler=heartbeat_error_handler  # Optional error callback
)

success = c.register()

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.8.tar.gz (5.2 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.8-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: srsrpy-0.2.8.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for srsrpy-0.2.8.tar.gz
Algorithm Hash digest
SHA256 2b967ca10047a36b41782127056690e7a5c6c4490679d7008b365799c6c33a1b
MD5 b37d943c217da6187d50080905ee74cf
BLAKE2b-256 1f32464011885df0d1d2ac2368ad395870aef050eb4c0dfaa57b12d5a3d9c7c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for srsrpy-0.2.8.tar.gz:

Publisher: srsrpy-release.yml on ifIMust/srsrpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: srsrpy-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for srsrpy-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 def510fad9bcbf9d8e5680d053b45440f877560cd32521ca159f75e348d0e910
MD5 f26d659ea6d5cd7464e1d066ce2ac252
BLAKE2b-256 890f9ca452782e060792c16e1f6494733c986f99c4e88c1b3c7da1cc5b2155cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for srsrpy-0.2.8-py3-none-any.whl:

Publisher: srsrpy-release.yml on ifIMust/srsrpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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