Metadata-Version: 2.4
Name: srsrpy
Version: 0.2.4
Summary: Really Simple Service Registry - Python Client
Project-URL: Documentation, https://github.com/ifIMust/srsrpy#readme
Project-URL: Source, https://github.com/ifIMust/srsrpy
Author-email: ifIMust <42818748+ifIMust@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.8
Requires-Dist: requests==2.32.4
Description-Content-Type: text/markdown

# 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.
