diff --git a/example/consumer/with_log_id/main.go b/example/consumer/with_log_id/main.go index 47703326..42d087fd 100644 --- a/example/consumer/with_log_id/main.go +++ b/example/consumer/with_log_id/main.go @@ -20,6 +20,7 @@ func main() { ConsumerGroupName: "test-consumer", ConsumerName: "test-consumer-1", CursorPosition: consumerLibrary.END_CURSOR, + Query: "", // query must be empty string or not initialized, GetCursor only support empty query } worker := consumerLibrary.InitConsumerWorkerWithCheckpointTracker(option, process_with_log_id) @@ -40,6 +41,7 @@ func process_with_log_id(shardId int, logGroupList *sls.LogGroupList, checkpoint // start consume logs for _, logGroup := range logGroupList.LogGroups { // logGroupCursor is empty string if failed + // only support consumer without query logGroupCursor := logGroup.GetCursor() fmt.Println("log group cursor: ", logGroupCursor) diff --git a/log_store.go b/log_store.go index d05e2d99..2322c005 100644 --- a/log_store.go +++ b/log_store.go @@ -642,7 +642,7 @@ func (s *LogStore) PullLogsWithQuery(plr *PullLogRequest) (gl *LogGroupList, plm if err != nil { return nil, nil, err } - if plm.Count > 0 && plm.readLastCursor != "" { + if plm.Count > 0 && plm.readLastCursor != "" && plr.Query == "" { gl.addCursorIfPossible(plm.readLastCursor) } return diff --git a/model.go b/model.go index 73f6a0f3..69d52f59 100644 --- a/model.go +++ b/model.go @@ -380,6 +380,7 @@ type ListStoreViewsResponse struct { } // If cursor is unknown, returns empty string +// If pullLogs with non-empty query or consumer with non-empty query, returns empty string func (l *LogGroup) GetCursor() string { return l.cursor }