Lamina.Server.Table (lamina v0.4.2)

A wrapper around ETS for our specific use cases.

Summary

Functions

Delete any expired rows from the ETS table.

Find the most likely configuration value for a given configuration key.

Get a specific configuration value from the ETS table.

Insert any number of configuration values into the ETS table.

Initialises a new ETS table.

Remove matching configuration values from the ETS table.

Types

@type lifetime() :: Lamina.Provider.lifetime()
@type provider() :: module()
@type t() :: :ets.tid()
@type value() :: any()

Functions

@spec expire(t()) :: :ok

Delete any expired rows from the ETS table.

Link to this function

get(table, config_key)

@spec get(t(), atom()) ::
  {:ok, Lamina.Server.ConfigValue.t()}
  | {:error, Lamina.Error.ConfigNotFoundError.t()}

Find the most likely configuration value for a given configuration key.

This executes a gently complicated match spec against the ETS table to find a configuration value which has the highest provider priority and is not expired.

Link to this function

get(table, config_key, provider)

@spec get(t(), atom(), provider()) ::
  {:ok, Lamina.Server.ConfigValue.t()}
  | {:error, Lamina.Error.ConfigNotFoundError.t()}

Get a specific configuration value from the ETS table.

Searches by config_key and provider only - does not take into account the row's expiry time.

Link to this function

insert(table, config_values)

@spec insert(t(), [Lamina.Server.ConfigValue.t()]) :: :ok

Insert any number of configuration values into the ETS table.

@spec new(module()) :: t()

Initialises a new ETS table.

Link to this function

remove(table, provider, config_key)

@spec remove(t(), provider(), config_key) :: :ok when config_key: atom()

Remove matching configuration values from the ETS table.