View Source Tesla.Middleware.Timeout (tesla v1.7.0)

Timeout HTTP request after X milliseconds.

examples

Examples

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.Timeout, timeout: 2_000
end

If you are using OpenTelemetry in your project, you may be interested in using OpentelemetryProcessPropagator.Task to have a better integration using the task_module option.

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.Timeout,
    timeout: 2_000,
    task_module: OpentelemetryProcessPropagator.Task
end

options

Options

  • :timeout - number of milliseconds a request is allowed to take (defaults to 1000)
  • :task_module - the Task module used to spawn tasks. Useful when you want use alternatives such as OpentelemetryProcessPropagator.Task from OTEL project.