Bandera.Config (bandera v0.1.0)

Copy Markdown

Resolves all Bandera settings at RUNTIME and caches them in a :persistent_term snapshot for cheap hot-path reads.

This module deliberately uses NO Application.compile_env/3. Every value is read from Application.get_env/3 and can be changed at runtime via reload/0, with no dependency recompilation. (Fixes fun_with_flags#122.)

Summary

Functions

Generate a random per-node id used to ignore self-published change notifications.

Whether the read cache is enabled (default true).

Cache time-to-live in seconds (default 900).

The SQL table name used by the Ecto adapter (default "bandera_flags").

The full notifications keyword config (adapter plus adapter-specific options).

The notifications adapter module (default Bandera.Notifications.Redis).

Whether cross-node cache-busting notifications are enabled (default false).

The full persistence keyword config (adapter plus adapter-specific options).

The persistence adapter module (default Bandera.Store.Persistent.Memory).

Re-read application env and rewrite the persistent_term snapshot.

Return the current snapshot, seeding it lazily if not yet present.

The active store module (default Bandera.Store.TwoLevel).

Types

snapshot()

@type snapshot() :: %{
  store: module(),
  cache_enabled?: boolean(),
  cache_ttl: non_neg_integer(),
  persistence_adapter: module(),
  persistence: keyword(),
  notifications_enabled?: boolean(),
  notifications_adapter: module(),
  notifications: keyword()
}

Functions

build_unique_id()

@spec build_unique_id() :: String.t()

Generate a random per-node id used to ignore self-published change notifications.

cache_enabled?()

@spec cache_enabled?() :: boolean()

Whether the read cache is enabled (default true).

cache_ttl()

@spec cache_ttl() :: non_neg_integer()

Cache time-to-live in seconds (default 900).

ecto_table_name()

@spec ecto_table_name() :: String.t()

The SQL table name used by the Ecto adapter (default "bandera_flags").

notifications()

@spec notifications() :: keyword()

The full notifications keyword config (adapter plus adapter-specific options).

notifications_adapter()

@spec notifications_adapter() :: module()

The notifications adapter module (default Bandera.Notifications.Redis).

notifications_enabled?()

@spec notifications_enabled?() :: boolean()

Whether cross-node cache-busting notifications are enabled (default false).

persistence()

@spec persistence() :: keyword()

The full persistence keyword config (adapter plus adapter-specific options).

persistence_adapter()

@spec persistence_adapter() :: module()

The persistence adapter module (default Bandera.Store.Persistent.Memory).

reload()

@spec reload() :: :ok

Re-read application env and rewrite the persistent_term snapshot.

snapshot()

@spec snapshot() :: snapshot()

Return the current snapshot, seeding it lazily if not yet present.

store()

@spec store() :: module()

The active store module (default Bandera.Store.TwoLevel).