Skip to content

Commit 8e36402

Browse files
authored
feat: add constraint for GetCUrsor (#304)
1 parent ba312b9 commit 8e36402

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

example/consumer/with_log_id/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func main() {
2020
ConsumerGroupName: "test-consumer",
2121
ConsumerName: "test-consumer-1",
2222
CursorPosition: consumerLibrary.END_CURSOR,
23+
Query: "", // query must be empty string or not initialized, GetCursor only support empty query
2324
}
2425

2526
worker := consumerLibrary.InitConsumerWorkerWithCheckpointTracker(option, process_with_log_id)
@@ -40,6 +41,7 @@ func process_with_log_id(shardId int, logGroupList *sls.LogGroupList, checkpoint
4041
// start consume logs
4142
for _, logGroup := range logGroupList.LogGroups {
4243
// logGroupCursor is empty string if failed
44+
// only support consumer without query
4345
logGroupCursor := logGroup.GetCursor()
4446
fmt.Println("log group cursor: ", logGroupCursor)
4547

log_store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ func (s *LogStore) PullLogsWithQuery(plr *PullLogRequest) (gl *LogGroupList, plm
642642
if err != nil {
643643
return nil, nil, err
644644
}
645-
if plm.Count > 0 && plm.readLastCursor != "" {
645+
if plm.Count > 0 && plm.readLastCursor != "" && plr.Query == "" {
646646
gl.addCursorIfPossible(plm.readLastCursor)
647647
}
648648
return

model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ type ListStoreViewsResponse struct {
380380
}
381381

382382
// If cursor is unknown, returns empty string
383+
// If pullLogs with non-empty query or consumer with non-empty query, returns empty string
383384
func (l *LogGroup) GetCursor() string {
384385
return l.cursor
385386
}

0 commit comments

Comments
 (0)