feat(ops): track broker balance worker failure lifecycle and backoff
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
59bb492883
commit
084e05a97d
@@ -52,10 +52,11 @@ class AccountSnapshotUnavailable(RuntimeError):
|
||||
"read_failed",
|
||||
})
|
||||
|
||||
def __init__(self, code: str) -> None:
|
||||
def __init__(self, code: str, *, detail_code: str | None = None) -> None:
|
||||
if code not in self._CODES:
|
||||
raise ValueError(f"unsupported account snapshot error code: {code}")
|
||||
self.code = code
|
||||
self.detail_code = detail_code
|
||||
super().__init__(f"account snapshot unavailable ({code})")
|
||||
|
||||
|
||||
@@ -217,7 +218,9 @@ class AccountSnapshotService:
|
||||
return self._broker.get_balance()
|
||||
except BrokerBalanceError as exc:
|
||||
if exc.code != "transport_failed":
|
||||
raise AccountSnapshotUnavailable("live_read_failed") from None
|
||||
raise AccountSnapshotUnavailable(
|
||||
"live_read_failed", detail_code=exc.code
|
||||
) from None
|
||||
snapshot = self._load_current()
|
||||
age = self._age(snapshot.holdings_captured_at, self._sell_max_age)
|
||||
_log.warning(
|
||||
|
||||
Reference in New Issue
Block a user