Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bigdatacesga/service-discovery
Python client for Consul Service Discovery API
https://github.com/bigdatacesga/service-discovery
Last synced: about 1 month ago
JSON representation
Python client for Consul Service Discovery API
- Host: GitHub
- URL: https://github.com/bigdatacesga/service-discovery
- Owner: bigdatacesga
- License: mit
- Created: 2016-04-26T20:38:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-03T13:51:47.000Z (over 5 years ago)
- Last Synced: 2024-10-31T17:08:57.551Z (about 1 month ago)
- Language: Python
- Size: 8.79 KB
- Stars: 15
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - bigdatacesga/service-discovery - Python client for Consul Service Discovery API (Python)
README
Consul Service Discovery API
----------------------------
This module provides a simple way to work with the
`Consul Service Discovery API `_
from python.Examples
--------
Usage examples::import consul
service = consul.Client()
service.register(id='flexlm1', name='flexlm',
address='10.112.0.211', port=28518,
tags=('flexlm1', light', 'v1'),
check={'id': 'flexlm', 'name': 'flexlm on port 28518',
'tcp': '10.112.0.211:28518',
'Interval': '30s', 'timeout': '2s'})
service.deregister(id='flexlm1')
service.list()
service.info(name='flexlm')The registration/deregistration is done using the consul agent API::
http://localhost:8500
PUT /v1/agent/service/register
PUT /v1/agent/service/deregister/To query the information the catalog API is used::
http://localhost:8500
GET /v1/catalog/services
GET /v1/catalog/service/bigdata
GET /v1/catalog/nodes
GET /v1/catalog/node/c13-9The payload for the registration request has the following format::
{
"ID": "flexlm1",
"Name": "flexlm",
"Tags": ["flexlm1", light", "v1"],
"Address": "10.112.0.211",
"Port": 28518,
"Check": {
"id": "flexlm",
"name": "flexlm on port 28518",
"tcp": "10.112.0.211:28518",
"Interval": "30s",
"timeout": "2s"
}
}