rincon-py is a client library for accessing the Rincon API.
rincon-py requires Python version 3.10 or above.
Install from PyPI with pip:
pip install rinconfrom rincon import RinconClient, Service, Route
client = RinconClient("http://localhost:10311")
# Register a service with routes
service = Service(
name="my-service",
version="1.0.0",
endpoint="http://localhost:5000",
health_check="http://localhost:5000/health",
)
routes = [
Route(route="/api/users", method="GET", service_name=""),
Route(route="/api/users", method="POST", service_name=""),
]
client.register(service, routes)
# Start client heartbeat to keep registration alive
client.start_heartbeat(interval=10.0)
# Discover services by route
matched = client.match_route("/api/users", "GET")
print(f"{matched.name} @ {matched.endpoint}")
# Cleanup
client.deregister()
client.close()The client also supports context managers for automatic cleanup:
with RinconClient("http://localhost:10311") as client:
client.register(service, routes)
client.start_heartbeat()
# ...If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b gh-username/my-amazing-feature) - Commit your Changes (
git commit -m 'Add my amazing feature') - Push to the Branch (
git push origin gh-username/my-amazing-feature) - Open a Pull Request