-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(streams): Add the possibility to have per stream ids #3793
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
59798a3
ce948f9
0291a77
e37e7a0
b649b81
6c092db
c7c4860
7d9af19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,10 +193,16 @@ func (c cmdable) XRevRangeN(ctx context.Context, stream, start, stop string, cou | |
| } | ||
|
|
||
| type XReadArgs struct { | ||
| Streams []string // list of streams and ids, e.g. stream1 stream2 id1 id2 | ||
| Streams []string // list of streams, or streams and ids e.g. stream1 stream2 id1 id2 | ||
| Count int64 | ||
| Block time.Duration | ||
| ID string | ||
| // ID is a single ID applied to every stream in Streams. | ||
| // When reading from multiple streams that require different IDs, | ||
| // use IDs instead so each stream can be resumed from its own last ID. | ||
| ID string | ||
| // IDs is the per-stream list of IDs (one per entry in Streams). | ||
| // When non-empty, IDs takes precedence over ID. | ||
| IDs []string | ||
| } | ||
|
|
||
| func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd { | ||
|
|
@@ -219,7 +225,12 @@ func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd { | |
| for _, s := range a.Streams { | ||
| args = append(args, s) | ||
| } | ||
| if a.ID != "" { | ||
| switch { | ||
| case len(a.IDs) > 0: | ||
| for _, id := range a.IDs { | ||
| args = append(args, id) | ||
| } | ||
| case a.ID != "": | ||
|
Comment on lines
+300
to
+305
|
||
| for range a.Streams { | ||
| args = append(args, a.ID) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Streamsfield comment says it can contain both stream names and IDs, butIDsis documented as "one per entry in Streams" (which only makes sense ifStreamscontains stream names only). This is contradictory and will confuse callers, especially now that there are multiple supported input shapes. Please clarify the docs to explicitly describe the supported encodings (legacyStreamscontaining keys+ids vsStreamscontaining only keys when usingID/IDs) and how they interact/are mutually exclusive.