-
Notifications
You must be signed in to change notification settings - Fork 0
/
MicroReg.py
56 lines (43 loc) · 1.38 KB
/
MicroReg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'''
MicroReg Client library
Allows the python client services to connect with the Registry Server to allow
the registration and other facilities provided through Registry Server.
'''
import xmlrpclib
class MicroRegClient:
'''
MicroRegClient defines the methods facilitating the connection with the
MicroReg Server.
'''
def __init__(self,host,port):
'''
Setup the connection with the MicroReg server.
'''
self.__connection_uri = str(host).rstrip('/') + ":" + str(port)
self.__client = xmlrpclib.ServerProxy(self.__connection_uri)
def register(self, name, host, port):
'''
Register a new service
'''
return self.__client.register(name, host, port)
def get_service_details(self, name):
'''
Get information about service
'''
return self.__client.get_service_details(name)
def get_all_service_details(self):
'''
Get information about all the services
'''
return self.__client.get_all_service_details()
def get_reg_count(self):
'''
Get the registration count of services currently registered with the
server
'''
return self.__client.get_reg_count()
def unregister(self, name):
'''
Unregister an existing service
'''
return self.__client.unregister(name)