项目作者: PrinsWu

项目描述 :
Find service from consul with consul query
高级语言: Python
项目地址: git://github.com/PrinsWu/consulservicefinder.git
创建时间: 2018-09-18T05:56:20Z
项目社区:https://github.com/PrinsWu/consulservicefinder

开源协议:MIT License

下载


Consul Service Finder

I got a problem when I try to simulate multiple service register on Consul server and the client can find one of the services to use the API.

I can use below URL to get all services but that is not what I want.

  1. curl http://localhost:8500/v1/agent/services

Ideas

* Consul Query to search service by service name

* Count the service be used

* Return min count of services by same service name

Example

  1. csf = ConsulServiceFinder()
  2. # create query by service name
  3. csf.createQueryByServiceName("microweb_microtalk", "q_test")
  4. # find one service and compose it's url
  5. csf.composeServiceUrl(csf.requestOneServiceByServiceName("microweb_microtalk"))