def get_dependency(self, worker_ctx): # Removing dead letter queue and backoff headers for key in self.dead_letter_properties + self.backoff_properties: if key in worker_ctx.data: worker_ctx.data.pop(key) return ServiceProxy(worker_ctx, self.target_service, self.rpc_reply_listener, **self.options)
def get(self, service, **options): try: res = self.proxy[service] except KeyError: res = self.proxy[service] = ServiceProxy(self.worker_ctx, service, self.rpc_reply_listener, **options) return res
def get_dependency(self, worker_ctx): if self.auth_service: self.collector.proxy = ServiceProxy(worker_ctx, self.auth_service, self.rpc_reply_listener) oauth2.service = worker_ctx.service services = dict( authorization_required=self.authorization_required, login_required=self.login_required, oauth2=self.oauth2 ) return self.make_dependency(**services)
def __init__( self, container_service_name, config, context_data=None, timeout=None, worker_ctx_cls=WorkerContext ): container = RpcProxy.ServiceContainer(config) reply_listener = SingleThreadedReplyListener(timeout=timeout) reply_listener.container = container worker_ctx = worker_ctx_cls( container, service=None, provider=self.DummyProvider, data=context_data) service_proxy = ServiceProxy(worker_ctx, container_service_name, reply_listener) self._reply_listener = reply_listener self._service_proxy = service_proxy
def __getattr__(self, name): if name not in self._proxies: self._proxies[name] = ServiceProxy(self._worker_ctx, name, self._reply_listener) return self._proxies[name]
def __init__(self, service_name, *args, **kwargs): super(ServiceRpcProxy, self).__init__(*args, **kwargs) self._proxy = ServiceProxy(self._worker_ctx, service_name, self._reply_listener)
def __getattr__(self, name): return ServiceProxy(self._worker_ctx, name, self._reply_listener)