Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
482cf88
docs: add Valkey cluster support design spec
claude May 19, 2026
b4f27a7
docs: clarify cluster-only deployment in Valkey cluster spec
claude May 19, 2026
53c079f
docs: add room key ensure RPC chunk to Valkey cluster spec
claude May 19, 2026
331d69b
docs: add Valkey cluster support implementation plan
claude May 19, 2026
7fef18f
chore(testimages): add ValkeyCluster image constant
claude May 19, 2026
e40963c
fix(roomkeystore): hash-tag key names for Valkey cluster slot consist…
claude May 19, 2026
ed8e319
feat(roomkeystore): add ClusterConfig, clusterAdapter, NewValkeyClust…
claude May 19, 2026
44ee638
test(roomkeystore): add cluster integration tests for clusterAdapter
claude May 19, 2026
1332b81
feat(valkeyutil): add ConnectCluster for Valkey cluster-mode support
claude May 19, 2026
75392a6
feat: migrate all services from VALKEY_ADDR to VALKEY_ADDRS (cluster …
claude May 19, 2026
660a796
feat: upgrade local-dev Valkey to cluster mode in all compose files
claude May 19, 2026
7c79cfa
feat(model,subject): add RoomKeyEnsure RPC types and subject builder
claude May 19, 2026
c45b4b8
feat(room-service): add NatsHandleEnsureRoomKey RPC
claude May 19, 2026
bc1828b
refactor: unify Valkey adapters via redis.UniversalClient, fix ping-f…
claude May 19, 2026
ec70392
Migrate all Valkey integration tests to cluster mode only
claude May 19, 2026
6ec9299
simplify: drop RoomKeyEnsureResponse, use RoomKeyEvent for ensure RPC…
claude May 19, 2026
7a2c80c
simplify: fix stale comment, remove unused ValkeyCluster constant, im…
claude May 19, 2026
87d3233
simplify: drop stale cross-file comment, remove visual section divider
claude May 19, 2026
c19f47f
simplify: remove two redundant doc comments
claude May 19, 2026
2699908
room-service: drop key bytes from EnsureRoomKey RPC response
claude May 19, 2026
ecedaa6
simplify: use roundTrip helper in RoomKeyEnsure JSON tests
claude May 19, 2026
c1abab9
fix(loadgen): migrate VALKEY_ADDR to VALKEY_ADDRS cluster API
claude May 19, 2026
45a231a
simplify: fix formatting + restore pool-leak comment in valkeyutil
claude May 19, 2026
e90f10a
fix: address CodeRabbit review comments
claude May 19, 2026
e6777e9
simplify: split broadcast-worker Valkey validation into two guards
claude May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion broadcast-worker/deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
# Set USER_CACHE_SIZE=0 to disable caching.
- USER_CACHE_SIZE=10000
- USER_CACHE_TTL=5m
- VALKEY_ADDR=valkey:6379
- VALKEY_ADDRS=valkey:6379
- VALKEY_KEY_GRACE_PERIOD=24h
- BOOTSTRAP_STREAMS=true
- ENCRYPTION_ENABLED=${ENCRYPTION_ENABLED:-false}
Expand Down
15 changes: 9 additions & 6 deletions broadcast-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type config struct {
UserCacheTTL time.Duration `env:"USER_CACHE_TTL" envDefault:"5m"`
RoomMetaCacheSize int `env:"ROOM_META_CACHE_SIZE" envDefault:"10000"`
RoomMetaCacheTTL time.Duration `env:"ROOM_META_CACHE_TTL" envDefault:"2m"`
ValkeyAddr string `env:"VALKEY_ADDR"`
ValkeyAddrs []string `env:"VALKEY_ADDRS" envSeparator:","`
ValkeyPassword string `env:"VALKEY_PASSWORD" envDefault:""`
ValkeyKeyGracePeriod time.Duration `env:"VALKEY_KEY_GRACE_PERIOD" envDefault:"24h"`
Consumer stream.ConsumerSettings `envPrefix:"CONSUMER_"`
Expand Down Expand Up @@ -88,14 +88,17 @@ func main() {

var keyStore roomkeystore.RoomKeyStore
if cfg.Encryption.Enabled {
if cfg.ValkeyAddr == "" || cfg.ValkeyKeyGracePeriod <= 0 {
slog.Error("encryption enabled but VALKEY_ADDR is empty or VALKEY_KEY_GRACE_PERIOD is not a positive duration",
"valkey_addr_set", cfg.ValkeyAddr != "",
if len(cfg.ValkeyAddrs) == 0 {
slog.Error("encryption enabled but VALKEY_ADDRS is empty")
os.Exit(1)
}
if cfg.ValkeyKeyGracePeriod <= 0 {
slog.Error("VALKEY_KEY_GRACE_PERIOD must be a positive duration",
"valkey_key_grace_period", cfg.ValkeyKeyGracePeriod)
os.Exit(1)
}
keyStore, err = roomkeystore.NewValkeyStore(roomkeystore.Config{
Addr: cfg.ValkeyAddr,
keyStore, err = roomkeystore.NewValkeyClusterStore(roomkeystore.ClusterConfig{
Addrs: cfg.ValkeyAddrs,
Password: cfg.ValkeyPassword,
GracePeriod: cfg.ValkeyKeyGracePeriod,
})
Expand Down
25 changes: 19 additions & 6 deletions docker-local/compose.deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,33 @@ services:
- chat-local

# Valkey backs the per-user restricted-rooms cache in search-service (5-min
# TTL, lazy-populated from Elasticsearch on miss). Persistence is disabled:
# the cache is derivative of the authoritative user-room ES doc and survives
# restart only through the lazy-populate path.
# TTL, lazy-populated from Elasticsearch on miss) and room key pairs for
# encryption. Persistence is disabled: the cache is derivative of the
# authoritative user-room ES doc and survives restart only through the
# lazy-populate path.
# Single-node cluster-mode: the entrypoint starts valkey-server with
# --cluster-enabled, waits for it to accept connections, then assigns all
# 16384 hash slots so it forms a valid one-node cluster.
valkey:
image: valkey/valkey:8-alpine
container_name: chat-local-valkey
ports:
- "6379:6379"
command: ["valkey-server", "--save", "", "--appendonly", "no"]
entrypoint:
- sh
- -c
- |
valkey-server --cluster-enabled yes --cluster-config-file /tmp/nodes.conf --cluster-node-timeout 5000 --save '' --appendonly no &
until valkey-cli ping > /dev/null 2>&1; do sleep 0.1; done
if ! valkey-cli CLUSTER INFO | grep -q 'cluster_slots_assigned:16384'; then
valkey-cli CLUSTER ADDSLOTSRANGE 0 16383
fi
wait
healthcheck:
test: ["CMD", "valkey-cli", "ping"]
test: ["CMD-SHELL", "valkey-cli CLUSTER INFO | grep 'cluster_state:ok'"]
interval: 5s
timeout: 3s
retries: 5
retries: 10
networks:
- chat-local

Expand Down
Loading
Loading