https://github.com/ifimust/srsrpy
Really Simple Service Registry - Python Client
https://github.com/ifimust/srsrpy
hatch microservices python
Last synced: 6 months ago
JSON representation
Really Simple Service Registry - Python Client
- Host: GitHub
- URL: https://github.com/ifimust/srsrpy
- Owner: ifIMust
- License: mit
- Created: 2024-08-06T18:57:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-12T17:29:17.000Z (over 1 year ago)
- Last Synced: 2025-06-09T13:23:59.536Z (7 months ago)
- Topics: hatch, microservices, python
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# srsr
Really Simple Service Registry - Python Client
## Description
This is the Python client for [srsr](https://github.com/ifIMust/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.