def test_error(self, server, url): ep = EndPoint(url) self.ep = ep availables = [] r = Request("", "a") for i in range(11): ep.call(r) availables.append(ep.available) assert False in availables gevent.sleep(0.2) assert ep.available r = Request("", "sum", 1, 2) assert ep.call(r).value == 3
def call(self, method, *args): if self.available: r = Request(self.service, method, *args) res = self.ha.call(r, self.lb) if res.exception: logger.error(str(res.exception)) raise res.exception return res.value raise ClientError("client not available")
def call(self, method: str, *args) -> Any: if self.available: r = Request(self.service, method, *args) res = self.filter.execute(r) if res.exception: logger.error(str(res.exception)) raise res.exception return res.value raise ClientError("client not available")
def test_endpoint(self, server, url): ep = EndPoint(url) self.ep = ep r = Request("", "sum", 1, 2) assert ep.call(r).value == 3
def test_br(self, server, lb): ha = BackupRequestHA(lb.url) r = Request("", "sum", 1, 2) assert ha.call(r, lb).value == 3 lb.url.set_param("sum.retries", 5) assert ha.call(r, lb).value == 3
def test_fail_over(self, server, lb): ha = FailOverHA(lb.url) r = Request("", "sum", 1, 2) assert ha.call(r, lb).value == 3
def function(*args): req = Request(self._name, method_name, *args[1:], meta=args[0]) res = self._filter.execute(req) if res.exception: raise res.exception return res.value