JsonApiClient v2.0.0 JsonApiClient.Middleware.Fuse View Source
Circuit Breaker middleware using fuse. In order to use this middleware the
fuse package must be added to your mix project and the fuse
and sasl
applications must be started. e.g:
defp deps do
[
{:fuse, "~> 2.4"}
]
end
defp applications do
[
extra_applications: [:sasl, :fuse]
]
end
Options
service_name -> :opts
- fuse options per service:opts
- fuse options when options are not configured per service (see fuse docs for reference)
config :json_api_client,
middlewares: [
{JsonApiClient.Middleware.Fuse,
opts: {{:standard, 2, 10_000}, {:reset, 60_000}},
service1: {{:standard, 10, 5_000}, {:reset, 120_000}},
}
]
In this example we’re specifying the default fuse options with opts
and
then specifying different fuse options for the service1
fuse. Fuses are
named based on the service_name
of the request, if present.
Link to this section Summary
Functions
Manipulates a Request and Response objects.
If the Request should be processed by the next middleware then next.(request)
has to be called
Link to this section Functions
Manipulates a Request and Response objects.
If the Request should be processed by the next middleware then next.(request)
has to be called.
Args:
request
- JsonApiClient.Request that holds http request properties.
This function returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
response
- HTTP response with the following properties:
body
- body as JSON string.status_code
- HTTP Status codeheaders
- HTTP headers (e.g.,[{"Accept", "application/json"}]
)
Callback implementation for JsonApiClient.Middleware.call/3
.