예제 #1
0
 def register_server(self):
     environment = dict_get(get_server_meta(), ["environment"])
     service = dict_get(get_server_meta(), ["name"])
     endpoint_parts = {
         'port': get_server_port(),
         'path': "api/%s" % self.name,
     }
     self.service_dir_client.set_endpoint(environment=environment,
                                          service=service,
                                          endpoint_parts=endpoint_parts)
예제 #2
0
 def register_server(self):
     environment = dict_get(get_server_meta(), ["environment"])
     service = dict_get(get_server_meta(), ["name"])
     endpoint_parts = {
         'port': get_server_port(),
         'path': "api/%s" % self.name,
     }
     self.service_dir_client.set_endpoint(
         environment=environment,
         service=service,
         endpoint_parts=endpoint_parts)
예제 #3
0
 def poll_endpoints(server_meta):
     # set server meta for this thread
     set_server_meta(server_meta)
     while True:
         self.service_endpoints = self.get_all_endpoints(
             environment=dict_get(
                 get_server_meta(),
                 ["environment"],
                 DEFAULT_ENVIRONMENT))
         sleep(SERVICE_UPDATE_INTERVAL)
예제 #4
0
 def get_all_endpoints(self, environment=None):
     if environment is None:
         return self.service_endpoints
     return dict_get(self.service_endpoints, [environment], {})
예제 #5
0
 def get_endpoint(self, environment=DEFAULT_ENVIRONMENT, service=None):
     return dict_get(self.service_endpoints, [environment, service], None)
예제 #6
0
 def get_services(self, environment=DEFAULT_ENVIRONMENT):
     return dict_get(self.service_endpoints, ['environment'], {}).keys()
예제 #7
0
def get_request_id():
    return dict_get(get_threadlocal(), ["request_meta", "request_id"], None)
예제 #8
0
 def get_server_name(self):
     return dict_get(get_server_meta(), ["name"])
예제 #9
0
def get_server_meta():
    server_meta = dict_get(get_threadlocal(), ["server_meta"], {})
    set_server_meta(server_meta)
    return server_meta
예제 #10
0
def get_request_meta():
    request_meta = dict_get(get_threadlocal(), ["request_meta"], {})
    # write back dictionary in case it was newly created
    set_request_meta(request_meta)
    return request_meta
예제 #11
0
 def get_server_name(self):
     return dict_get(get_server_meta(), ["name"])
예제 #12
0
def get_server_meta():
    server_meta = dict_get(get_threadlocal(), ["server_meta"], {})
    set_server_meta(server_meta)
    return server_meta
예제 #13
0
def get_request_meta():
    request_meta = dict_get(get_threadlocal(), ["request_meta"], {})
    # write back dictionary in case it was newly created
    set_request_meta(request_meta)
    return request_meta
예제 #14
0
def get_request_id():
    return dict_get(get_threadlocal(), ["request_meta", "request_id"], None)