Unleash.Client behaviour (Unleash v5.1.2)

View Source

HTTP Client responsible for communicating with the Unleash API Server.

Summary

Types

Type representing the result of attempting to fetch features from the Unleash API.

A JSON-serialisable payload POSTed to the Unleash API (register/metrics).

Result of a register/metrics POST to the Unleash API.

Functions

Fetches features from the Unleash API, sending etag for HTTP caching. See features_result/0.

Sends a metrics bucket to the Unleash API.

Registers the given client payload with the Unleash API.

Registers this client instance with the Unleash API, advertising its configured strategies.

Types

features_result()

@type features_result() ::
  {String.t(), Unleash.Features.t()} | {nil, atom() | String.t()} | :cached

Type representing the result of attempting to fetch features from the Unleash API.

It can be:

  • {etag, features} when fetched fresh features from the API and correspondent new HTTP etag.
  • {nil, reason} in case of errors.
  • :cached in case of HTTP-level caching

payload()

@type payload() :: map()

A JSON-serialisable payload POSTed to the Unleash API (register/metrics).

post_result()

@type post_result() :: {:ok, Req.Response.t()} | {:error, atom() | String.t()}

Result of a register/metrics POST to the Unleash API.

Callbacks

features(t)

@callback features(String.t()) :: features_result()

metrics(payload)

@callback metrics(payload()) :: post_result()

register_client()

@callback register_client() :: post_result()

Functions

features(etag \\ nil)

@spec features(String.t() | nil) :: features_result()

Fetches features from the Unleash API, sending etag for HTTP caching. See features_result/0.

metrics(met)

@spec metrics(payload()) :: post_result()

Sends a metrics bucket to the Unleash API.

register(client)

@spec register(payload()) :: post_result()

Registers the given client payload with the Unleash API.

register_client()

@spec register_client() :: post_result()

Registers this client instance with the Unleash API, advertising its configured strategies.