Skip to content

Deprecate LastConsumed method #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
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
23 changes: 18 additions & 5 deletions pkg/stream/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,12 @@ func (consumer *Consumer) QueryOffset() (int64, error) {
SetOffset constants
*/
const (
typeFirst = int16(1)
typeLast = int16(2)
typeNext = int16(3)
typeOffset = int16(4)
typeTimestamp = int16(5)
typeFirst = int16(1)
typeLast = int16(2)
typeNext = int16(3)
typeOffset = int16(4)
typeTimestamp = int16(5)
// Deprecated: see LastConsumed()
typeLastConsumed = int16(6)
)

Expand Down Expand Up @@ -476,13 +477,25 @@ func (o OffsetSpecification) isOffset() bool {
return o.typeOfs == typeOffset || o.typeOfs == typeLastConsumed
}

// Deprecated: see LastConsumed()
func (o OffsetSpecification) isLastConsumed() bool {
return o.typeOfs == typeLastConsumed
}
func (o OffsetSpecification) isTimestamp() bool {
return o.typeOfs == typeTimestamp
}

// Deprecated: The method name may be misleading.
// The method does not indicate the last message consumed of the stream but the last stored offset.
// The method was added to help the user, but it created confusion.
// Use `QueryOffset` instead.:
//
// offset, err := env.QueryOffset(consumerName, streamName)
// // check the error
// ....
// SetOffset(stream.OffsetSpecification{}.Offset(offset)).
//
// So in this way it possible to start from the last offset stored and customize the behavior
func (o OffsetSpecification) LastConsumed() OffsetSpecification {
o.typeOfs = typeLastConsumed
o.offset = -1
Expand Down