RedisCluster.Configuration (redis_cluster v0.8.0)

View Source

A struct to hold the configuration for working with a Redis cluster.

SSL Support

SSL/TLS connections can be enabled by setting ssl: true and providing SSL options via ssl_opts. The SSL options are passed directly to Redix as socket options.

Common SSL options include:

  • verify: :verify_peer - Enable certificate verification
  • cacertfile: path - Path to CA certificate file
  • certfile: path - Path to client certificate file
  • keyfile: path - Path to client private key file
  • server_name_indication: 'hostname' - SNI hostname for verification

Example configuration with SSL:

config :my_app, MyApp.RedisCluster,
  host: "my-redis-cluster.example.com",
  port: 6379,
  pool_size: 10,
  ssl: true,
  ssl_opts: [
    verify: :verify_peer,
    cacertfile: "/path/to/ca.crt"
  ]

Summary

Types

t()

A struct representing the configuration for a Redis cluster.

Functions

A convenience function to create a configuration struct from application environment.

Types

t()

@type t() :: %RedisCluster.Configuration{
  cluster: atom(),
  host: String.t(),
  name: atom(),
  pool: atom(),
  pool_size: non_neg_integer(),
  port: non_neg_integer(),
  redis_module: module(),
  registry: atom(),
  shard_discovery: atom(),
  ssl: boolean(),
  ssl_opts: keyword()
}

A struct representing the configuration for a Redis cluster.

The key elements are the host, port, and pool size. The other fields are used to uniquely identify different processes.

Fields:

  • host - Redis cluster endpoint hostname
  • port - Redis cluster endpoint port
  • pool_size - Number of connections per Redis node
  • ssl - Enable SSL/TLS connections (default: false)
  • ssl_opts - SSL options passed to Redix socket_opts (default: [])
  • redis_module - Module used for Redis connections (default: Redix)
  • Other fields are process identifiers for internal use

Functions

from_app_env(opts, module)

@spec from_app_env(Keyword.t(), atom()) :: t()

A convenience function to create a configuration struct from application environment.

This is intended for the RedisCluster module. If you create your own config struct, then do so directly using struct syntax:

%RedisCluster.Configuration{
  host: "localhost",
  port: 6379,
  name: MyApp.RedisCluster,
  registry: MyApp.RedisCluster.Registry,
  cluster: MyApp.RedisCluster.Cluster,
  pool: MyApp.RedisCluster.Pool,
  shard_discovery: MyApp.RedisCluster.ShardDiscovery,
  pool_size: 10,
  ssl: false,
  ssl_opts: []
}