Skip to content

Commit

Permalink
[azeventhubs] Default start position is supposed to be latest, not ea…
Browse files Browse the repository at this point in the history
…rliest Azure#18863
  • Loading branch information
richardpark-msft authored Aug 11, 2022
1 parent 15a7d71 commit dab96a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sdk/messaging/azeventhubs/consumer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ConsumerClientOptions struct {
}

// StartPosition indicates the position to start receiving events within a partition.
// The default position is Latest.
type StartPosition struct {
// Offset will start the consumer after the specified offset. Can be exclusive
// or inclusive, based on the Inclusive property.
Expand Down Expand Up @@ -272,7 +273,7 @@ func getOffsetExpression(startPosition StartPosition) (string, error) {
}

// default to the start
return "amqp.annotation.x-opt-offset > '-1'", nil
return "amqp.annotation.x-opt-offset > '@latest'", nil
}

func formatOffsetExpressionForSequence(op string, sequenceNumber int64) string {
Expand Down
2 changes: 1 addition & 1 deletion sdk/messaging/azeventhubs/consumer_client_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestUnit_getOffsetExpression(t *testing.T) {
t.Run("Valid", func(t *testing.T) {
expr, err := getOffsetExpression(StartPosition{})
require.NoError(t, err)
require.Equal(t, "amqp.annotation.x-opt-offset > '-1'", expr)
require.Equal(t, "amqp.annotation.x-opt-offset > '@latest'", expr)

expr, err = getOffsetExpression(StartPosition{Earliest: to.Ptr(true)})
require.NoError(t, err)
Expand Down

0 comments on commit dab96a8

Please sign in to comment.