inaka / Dayron

A repository `similar` to Ecto.Repo that maps to an underlying http client, sending requests to an external rest api instead of a database
http://inaka.net/blog/2016/05/24/introducing-dayron/
Apache License 2.0
159 stars 20 forks source link

Circuit breaker integration #51

Closed lucacorti closed 2 years ago

lucacorti commented 8 years ago

When dealing with external services an important part of the equation is circuit breaking logic to avoid long timeouts during outages or network congestion. Is anything like this already planned?

flaviogranero commented 8 years ago

hi @lucacorti ,

currently we're sending options directly to HTTPoison client, so you can set a short timeout if needed https://github.com/inaka/Dayron/blob/master/lib/dayron/adapter.ex#L32.

Do you mean to provide something more specific, such as sending a message to the client to cancel the current request? If you have some example, it'll be appreciated :)

lucacorti commented 8 years ago

Hi @flaviogranero, thanks for taking the time to reply.

Short timeouts are nice to have, but I was thinking about circuit breaking logic to skip requests altogether in case the requested service is unavailable/unreachable. This allows the client to fail immediately on outages and is particularly helpful when you have to deal with multiple different services, especially when dealing with microservice environments.

Fuse is an Erlang implementation of this kind of behavior: https://github.com/jlouis/fuse