RedisServerWrapper.Config (redis_server_wrapper v0.7.4)

Copy Markdown View Source

Redis server configuration builder.

Generates redis.conf content from a structured configuration. Supports common Redis directives plus token-safe :extra directives for anything else. Every value is encoded as a Redis configuration token.

Summary

Types

A Redis module path, optionally paired with an argument vector.

t()

Functions

Builds the client connection used to control this Redis server.

Returns the address used by redis-cli and lifecycle probes.

Encodes one Redis configuration directive from an argument vector.

Returns normalized Redis listen-address tokens.

Creates a new config from keyword options.

Generates redis.conf file content from the config.

Types

append_fsync()

@type append_fsync() :: :always | :everysec | :no

bind_addresses()

@type bind_addresses() :: String.t() | [String.t()]

extra_spec()

@type extra_spec() :: {String.t(), String.t() | [String.t()]}

log_level()

@type log_level() :: :debug | :verbose | :notice | :warning

module_spec()

@type module_spec() :: String.t() | {String.t(), [String.t()]}

A Redis module path, optionally paired with an argument vector.

A plain string is one module-path token. Use {path, args} when arguments are needed; paths and arguments are always quoted safely when required.

save_policy()

@type save_policy() :: :disabled | :default | [{pos_integer(), pos_integer()}]

t()

@type t() :: %RedisServerWrapper.Config{
  appendfsync: append_fsync(),
  appendonly: boolean(),
  bind: bind_addresses(),
  cluster_announce_bus_port: non_neg_integer() | nil,
  cluster_announce_hostname: String.t() | nil,
  cluster_announce_port: non_neg_integer() | nil,
  cluster_config_file: String.t() | nil,
  cluster_enabled: boolean(),
  cluster_node_timeout: non_neg_integer() | nil,
  control_host: String.t() | nil,
  daemonize: boolean(),
  dir: String.t() | nil,
  extra: [extra_spec()],
  loadmodule: [module_spec()],
  logfile: String.t() | nil,
  loglevel: log_level(),
  masterauth: String.t() | nil,
  masteruser: String.t() | nil,
  maxmemory: String.t() | nil,
  maxmemory_policy: String.t() | nil,
  password: String.t() | nil,
  pidfile: String.t() | nil,
  port: non_neg_integer(),
  replicaof: {String.t(), non_neg_integer()} | nil,
  save: save_policy(),
  tcp_backlog: non_neg_integer() | nil,
  tcp_keepalive: non_neg_integer() | nil,
  timeout: non_neg_integer() | nil,
  tls_auth_clients: String.t() | nil,
  tls_ca_cert_dir: String.t() | nil,
  tls_ca_cert_file: String.t() | nil,
  tls_cert_file: String.t() | nil,
  tls_client_cert_file: String.t() | nil,
  tls_client_key_file: String.t() | nil,
  tls_cluster: boolean(),
  tls_insecure: boolean(),
  tls_key_file: String.t() | nil,
  tls_port: non_neg_integer() | nil,
  tls_replication: boolean(),
  tls_server_name: String.t() | nil,
  unixsocket: String.t() | nil,
  unixsocketperm: String.t() | nil,
  username: String.t() | nil
}

Functions

connection(config)

@spec connection(t()) :: RedisServerWrapper.Connection.t()

Builds the client connection used to control this Redis server.

control_host(config)

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

Returns the address used by redis-cli and lifecycle probes.

:bind controls Redis listen addresses. Set :control_host when Redis listens on multiple addresses or on a wildcard address.

directive(key, values)

@spec directive(String.t(), [term()]) :: String.t()

Encodes one Redis configuration directive from an argument vector.

This is also used by the Sentinel configuration generator so it follows the same quoting and escaping rules as redis.conf.

listen_addresses(config)

@spec listen_addresses(t()) :: [String.t()]

Returns normalized Redis listen-address tokens.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new config from keyword options.

Config.new(port: 6400, password: "secret", appendonly: true)

Config.new(
  loadmodule: [
    {"/path/to/module.so", ["events", "expired,set", "maxlen", "10000"]}
  ]
)

to_config_string(config)

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

Generates redis.conf file content from the config.