def blacklist(self, key, request): exchange = request['exchange'] call = request['call'] args = request['args'] ticker_id = request['ticker_id'] request["processor_id"] = self._processor_id for ticker in list(self._list_ticker(get_ticker_key(request))): self.stop(key, ticker.get_config()) if self._configuration_service.leader_event.is_set(): current, _ = self._configuration_service.get_config( configurationService.combine_path( ["blacklist", exchange, call, str(args).replace('/', '_')])) for config in current.values(): old_ticker_id = config['ticker_id'] self._configuration_service.del_config( configurationService.combine_path([ "blacklist", exchange, call, str(args).replace('/', '_') ]), old_ticker_id) self._configuration_service.put_config( configurationService.combine_path( ["blacklist", exchange, call, str(args).replace('/', '_')]), ticker_id, request) status = {**request, **{"id": key, "result": "blacklist"}} self._status_producer.send(key=key, value=status)
def deregister(self): logging.info("Deregister ticker config {}".format(self.ticker_id)) self._configuration_service.del_status("ticker", str(self.ticker_id)) if self._configuration_service.leader_event.is_set(): self._configuration_service.del_config( configurationService.combine_path([ "ticker", self.exchange, self.call, str(self.args).replace('/', '_') ]), str(self.ticker_id))
def put_config(self): config = self.get_config() if self._configuration_service.leader_event.is_set(): self._configuration_service.put_config( configurationService.combine_path([ "ticker", self.exchange, self.call, str(self.args).replace('/', '_') ]), str(self.ticker_id), config) return config
def _check_blacklisted(self, request): exchange = request['exchange'] call = request['call'] args = request['args'] request_key = get_ticker_key(request) current, _ = self._configuration_service.get_config( configurationService.combine_path( ["blacklist", exchange, call, str(args).replace('/', '_')])) blacklisted = False for config in current.values(): blacklist_key = get_ticker_key(config) if request_key == blacklist_key: blacklisted = True break return blacklisted