Lamina.Server.Impl (lamina v0.4.2)

Separates the functional implementation from the stateful GenServer.

Summary

Functions

Query provider for the latest config_key.

Initialise the table and server state from the provided options.

If config_value is volatile, then ask the Lamina server to make sure that it has the freshest information.

Refreshes all configuration for a provider.

Call config_change/2 on all providers with a function which they can use to trigger refreshes.

Types

Link to this type

config_key()

@type config_key() :: atom()
@type provider() :: module()

Functions

Link to this function

get_latest_value(provider, config_key, state)

@spec get_latest_value(provider(), config_key(), Lamina.Server.State.t()) ::
  {:ok, Lamina.Server.State.t()}
  | {:ok, Lamina.Server.ConfigValue.t(), Lamina.Server.State.t()}
  | {:error, any()}

Query provider for the latest config_key.

If the provider has a new value, and it is different to the old value, then broadcast the change to subscribers, and call the config module's config_change/3 callback.

@spec init(
  nonempty_improper_list(
    module(),
    keyword()
  )
) :: {:ok, Lamina.Server.State.t()} | {:error, any()}

Initialise the table and server state from the provided options.

Link to this function

maybe_get_latest(pid, config_value)

@spec maybe_get_latest(pid(), Lamina.Server.ConfigValue.t()) ::
  {:ok, Lamina.Server.ConfigValue.t()} | {:error, any()}

If config_value is volatile, then ask the Lamina server to make sure that it has the freshest information.

Link to this function

refresh_provider(provider, state)

@spec refresh_provider(provider(), Lamina.Server.State.t()) ::
  {:ok, Lamina.Server.State} | {:error, any()}

Refreshes all configuration for a provider.

Link to this function

set_provider_config_change_callbacks(state)

@spec set_provider_config_change_callbacks(Lamina.Server.State.t()) ::
  {:ok, Lamina.Server.State} | {:error, any()}

Call config_change/2 on all providers with a function which they can use to trigger refreshes.