ExBifrost.Connection (ex_bifrost v0.1.0)

Copy Markdown View Source

Handle Tesla connections for ExBifrost.

Extends the stock openapi-generator connection with production defaults:

Additional middleware and an alternative adapter can be set in the compile-time or runtime configuration:

config :tesla, ExBifrost.Connection,
  base_url: "http://localhost:8080",
  adapter: Tesla.Adapter.Hackney

The default base URL can also be set as:

config :ex_bifrost,
  :base_url, "http://localhost:8080"

Summary

Types

The list of options that can be passed to new/1.

Functions

Returns the default adapter for this API.

Returns fully configured middleware for passing to Tesla.client/2.

Configure a ExBifrost client.

Forward requests to Tesla.

Types

options()

@type options() :: [
  base_url: String.t(),
  user_agent: String.t(),
  adapter: Tesla.Client.adapter(),
  timeout: non_neg_integer(),
  retry: keyword() | false,
  middleware: [Tesla.Client.middleware()],
  username: String.t() | nil,
  password: String.t() | nil,
  bearer_token: String.t() | nil
]

The list of options that can be passed to new/1.

  • base_url: Overrides the base URL on a per-client basis.
  • user_agent: Overrides the User-Agent header.
  • adapter: Overrides the Tesla adapter (defaults to Finch).
  • timeout: Per-request timeout in milliseconds (default: 30_000).
  • retry: Retry configuration keyword list, or false to disable retries.
    • max_retries: Maximum number of retries (default: 3)
    • delay: Initial backoff delay in milliseconds (default: 100)
    • max_delay: Maximum backoff delay in milliseconds (default: 5_000)
    • should_retry: Custom arity-3 retry predicate
  • middleware: Additional Tesla middleware (appended to the stack).
  • username: A username for basic authentication.
  • password: A password for basic authentication.
  • bearer_token: A bearer token for bearer authentication.

Functions

adapter()

Returns the default adapter for this API.

Defaults to Finch (pooled by ExBifrost.Application) and can be overridden with:

config :tesla, ExBifrost.Connection, adapter: Tesla.Adapter.Hackney

middleware(options \\ [])

@spec middleware(options()) :: [Tesla.Client.middleware()]

Returns fully configured middleware for passing to Tesla.client/2.

new(options \\ [])

@spec new(options()) :: Tesla.Env.client()

Configure a ExBifrost client.

Parameters

  • options: an optional keyword list of ExBifrost.Connection.options.

Returns

Tesla.Env.client

request(client, options)

@spec request(Tesla.Client.t(), [Tesla.option()]) :: Tesla.Env.result()

Forward requests to Tesla.