26 lines
1.2 KiB
Go
26 lines
1.2 KiB
Go
package ports
|
|
|
|
import "context"
|
|
|
|
//go:generate go run go.uber.org/mock/mockgen -destination=../adapters/mocks/mock_streamoffsetstore.go -package=mocks galaxy/gamemaster/internal/ports StreamOffsetStore
|
|
|
|
// StreamOffsetStore persists the last successfully processed Redis
|
|
// Stream entry id per consumer label. 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. The label is the short logical identifier of
|
|
// the consumer (e.g., `health_events`), not the full stream name; it
|
|
// stays stable when the underlying stream key is renamed.
|
|
type StreamOffsetStore interface {
|
|
// Load returns the last processed entry id for the consumer
|
|
// labelled 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 the
|
|
// consumer labelled stream. Implementations overwrite any previous
|
|
// value unconditionally.
|
|
Save(ctx context.Context, stream, entryID string) error
|
|
}
|