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.6.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.6-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: srsrpy-0.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 7217dc3d50827247e5d149f3737ac6d9ab1844903d807d3d83a83fc7c4e8935f
MD5 f61f6a38057316c6f2fc3adb54189056
BLAKE2b-256 b5888e434999cf9e983e4563f3f9e037000ae7f130c25a45b71d0ad5bdc54bd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for srsrpy-0.2.6.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.6-py3-none-any.whl.

File metadata

  • Download URL: srsrpy-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 3.5 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 75d1b1aefb0ec7d36595efe211543b3221d0069831f25ddda9b8133192b4a9fc
MD5 1e97766e20238a59c605827b96e86514
BLAKE2b-256 f750604b38421c67b039ad3b4614369671e38e89cca2b52d9f0aa8eef2920234

See more details on using hashes here.

Provenance

The following attestation bundles were made for srsrpy-0.2.6-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