Skip to content

feat(redis)!: Redis connections come from the app's config - #15

Closed
arjendevos wants to merge 5 commits into
feat/cache-configfrom
feat/redis-config
Closed

arjendevos wants to merge 5 commits into
feat/cache-configfrom
feat/redis-config

Conversation

@arjendevos

@arjendevos arjendevos commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #14. The last of the environment reads in core.

The queue and the cache built their Redis connections from REDIS_* (or REDIS_<NAME>_*) environment variables. The app now registers its connections once and they look theirs up by name:

app.WithRedis(config.Redis{Connections: map[config.RedisConnectionType]config.RedisConnection{
	config.DefaultRedisConnection: {Host: "redis", Port: "6379", Password: "..."},
	"queue": {Mode: config.SentinelRedisMode, Addresses: []string{"sentinel-1:26379"}, MasterName: "queue"},
}})
  • config.RedisConnection gains what the environment gave: Mode (config.SingleRedisMode by default, SentinelRedisMode or ClusterRedisMode; its type is private, read it with env.Enum), Addresses (or Host and Port for one), MasterName and the sentinel credentials.
  • A connection asked for before app.WithRedis fails; a name the config lacks is an error, as is a bad mode, a database outside 0 to 15, or a cluster on another database.
  • config.Queue.Connections.Redis.Connection and config.Cache.Connection name the one they use, the default when empty.

Breaking: Redis connections need app.WithRedis; REDIS_* is no longer read.

Tested: tests/redis (moved from redis/) covers no config, the default connection, a named sentinel one, a cluster and each refusal. The live connection test still runs with REDIS_TOPOLOGY_INTEGRATION=1, and passed against a local Redis.

The queue and the cache built their Redis connections from REDIS_* or
REDIS_<NAME>_* environment variables. The app now registers its
connections once, app.WithRedis(config.Redis), and they look theirs up
by name; one asked for before that fails with ErrNoConfig, and a name
the config lacks is an error. config.RedisConnection gains the mode,
addresses, master name and sentinel credentials the environment gave.

BREAKING CHANGE: Redis connections need app.WithRedis; REDIS_* is no
longer read.

Copy link
Copy Markdown
Contributor Author

Folded into #18.

@arjendevos arjendevos closed this Nov 23, 2026
@arjendevos
arjendevos deleted the feat/redis-config branch November 23, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant