ASM.Extensions.Routing.Strategy behaviour (ASM v0.9.2)

Copy Markdown View Source

Selection strategy contract for routing provider candidates.

Summary

Types

Router candidate metadata presented to strategies.

Opaque strategy state.

Types

candidate()

@type candidate() :: %{
  id: term(),
  provider: atom(),
  provider_opts: keyword(),
  priority: integer(),
  weight: pos_integer(),
  position: non_neg_integer()
}

Router candidate metadata presented to strategies.

state()

@type state() :: term()

Opaque strategy state.

Callbacks

choose(list, state, keyword)

@callback choose([candidate()], state(), keyword()) ::
  {:ok, candidate(), state()} | :none | {:error, ASM.Error.t()}

init(keyword)

@callback init(keyword()) :: {:ok, state()} | {:error, ASM.Error.t()}