Replies: 5 comments 1 reply
-
dumb question -> https://hyx.readthedocs.io/en/latest/ |
Beta Was this translation helpful? Give feedback.
-
@dicolasi there is no dump question :D Thanks for showing some interest in Hyx 🙌 Yes, that's our main doc source https://hyx.readthedocs.io/en/latest/ Also, feel free to talk a bit about your usecase. Want to make sure Hyx is aligned with its users needs 👀 |
Beta Was this translation helpful? Give feedback.
-
@roma-glushko I am using it in FastAPI app. I am interested in using retry for now. However, not convinced that this is the right way to use it:
should I use an event specific to FastAPI instead of httpx? |
Beta Was this translation helpful? Give feedback.
-
for instance, would it be possible to use a general master circuit breaker rather than annotate all the methods? |
Beta Was this translation helpful? Give feedback.
-
Based on the snippet, I could see you are trying to use for the client that hits some API. This is perfectly fine to decorate that So I would remove that from hyx.retry.exceptions import AttemptsExceeded
try:
details = client.get_details("London")
except AttemptsExceeded:
# handle cases when the API is completely down
...
This sounds like a great idea to have this sort of manager in Hyx. The current circuit breaker implementation is rather suited for gatekeeping one operation/workflow, just like resiliency4j if I remember correctly. But having this higher level component would make a use of circuit breakers even easier. I could imagine one initing circuit breaker manager somewhere in a dependency injection container and then pass it further to relevant places where breaker's functionality needed like: from typing import Any
import httpx
class CurrencyRate:
...
class CurrencyRates:
def __init__(self, breaker_manager: CircuitBreakerManager) -> None:
self._breaker_manager = breaker_manager
async def get_rates(self) -> list[CurrencyRate]:
with self.breaker_manager("currency.rates", exceptions=(httpx.NetworkError,)): # manager creates/retrieves and activates breaker
async with httpx.AsyncClient() as client:
response = await client.get("https://api.github.com/events")
return self._map_rates(response.json())
def _map_rates(self, data: list[dict[str, Any]]) -> list[CurrencyRate]:
... Let me know if this is what you had on mind. I will create a task to bring this into Hyx. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Coming from resilience4j, I have no idea how to use this nice library. Am I missing the docs?
Beta Was this translation helpful? Give feedback.
All reactions