Files
galaxy-game/lobby/internal/ports/streamoffsetstore.go
T
2026-04-25 23:20:55 +02:00

21 lines
920 B
Go

package ports
import "context"
// StreamOffsetStore persists the last successfully processed Redis
// Stream entry id per stream. Workers call Load on startup to resume
// from the persisted offset and Save after every successful message
// handling so the next iteration advances past the just-processed
// entry. Lobby uses one logical store with the per-stream key encoded
// inside the implementation.
type StreamOffsetStore interface {
// Load returns the last processed entry id for stream when one is
// stored. The boolean return reports whether a value was present;
// implementations must not return an error for a missing key.
Load(ctx context.Context, stream string) (entryID string, found bool, err error)
// Save stores entryID as the new last processed offset for stream.
// Implementations overwrite any previous value unconditionally.
Save(ctx context.Context, stream, entryID string) error
}