Metadata-Version: 2.3
Name: srsrpy
Version: 0.2.0
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
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
c = srsrpy.ServiceRegistryClient('http://server.address.com:8080', 'service_name', 'http://client.address.net:3333')
# Returns True if registered
success = c.register()

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

# At teardown time, deregister
c.deregister()
```

### Shutdown using interrupt handler
```
import signal
try:
    svc_reg = ServiceRegistryClient('http://server_hostname', 'service_name', 'http://client_hostname')
    svc_reg.register()

    # Assume registration was successful. Deregister on Ctrl-C
    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)
except:
    print("Couldn't connect to registry server.")
```


## Further plans
- Publish the client to the PyPI production server
- Handle failed heartbeat, by stopping the thread.
