24 lines
1.0 KiB
Go
24 lines
1.0 KiB
Go
package ports
|
|
|
|
import "context"
|
|
|
|
// 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. `start_jobs`, `stop_jobs`), 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
|
|
}
|