Reputation: 879
I am trying to register some services and use it as a service discovery using Apache Zookeeper and implementing it in python using the Kazoo library. Having a hard time to figure out how to trigger the API call from zookeeper and redirect the HTTP request to the required API
Suppose I have a basic website running on my localhost and I want to register some of its APIs using kazoo into zookeeper and reach them when necessary
some routes of my websites are :
127.0.0.1:8000/register
127.0.0.1:8000/login
127.0.0.1:8000/login/auth
127.0.0.1:8000/home
127.0.0.1:8000/jasmine/Oauth/run
import logging
import time
from kazoo.client import KazooClient
from kazoo.client import KazooState
zk = KazooClient(hosts='127.0.0.1:2181')
zk.start()
zk.ensure_path("127.0.0.1:8000/")
if zk.exists("127.0.0.1:8000/"):
print('found')
data, stat = zk.get("127.0.0.1:8000/")
print("Version: %s, data: %s" % (stat.version, data.decode("utf-8")))
children = zk.get_children("127.0.0.1:8000/")
print("There are %s children with names %s" % (len(children), children))
zk.stop()
I am not able to register any services mentioned above and also tried another library "zc.zk". It gives me an error
File "/home/root/.local/lib/python3.5/site-packages/zc/zk/init.py", line 259 print 'extra path not trimmed:', cpath
Can you please point me in the right direction where should I start registering services and get the data in return. And use my python script as an orchestrator to my incoming requests
Your help would be much appreciated. Thank you in advance
Upvotes: 1
Views: 671