32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
// Package redisstate hosts the small surface of Redis state that survived the
|
|
// PG_PLAN.md §4 migration: the inbound `mail:delivery_commands` stream and
|
|
// the persisted offset of its consumer. Every other durable record (auth and
|
|
// generic acceptance, attempt execution, malformed commands, dead letters,
|
|
// operator listing) now lives in PostgreSQL via `mailstore`.
|
|
package redisstate
|
|
|
|
import "encoding/base64"
|
|
|
|
const defaultPrefix = "mail:"
|
|
|
|
// Keyspace builds the small surviving Mail Service Redis keyspace. Dynamic
|
|
// segments (the stream key embedded in the offset key) are encoded with
|
|
// base64url so raw key structure does not depend on caller-provided
|
|
// characters.
|
|
type Keyspace struct{}
|
|
|
|
// StreamOffset returns the primary Redis key for one persisted stream-consumer
|
|
// offset.
|
|
func (Keyspace) StreamOffset(stream string) string {
|
|
return defaultPrefix + "stream_offsets:" + encodeKeyComponent(stream)
|
|
}
|
|
|
|
// DeliveryCommands returns the frozen async ingress Redis Stream key.
|
|
func (Keyspace) DeliveryCommands() string {
|
|
return defaultPrefix + "delivery_commands"
|
|
}
|
|
|
|
func encodeKeyComponent(value string) string {
|
|
return base64.RawURLEncoding.EncodeToString([]byte(value))
|
|
}
|