Skip to content

Commit 28f91b8

Browse files
committed
fix: cursor + block for xreadgroup
1 parent 5454679 commit 28f91b8

File tree

12 files changed

+152
-222
lines changed

12 files changed

+152
-222
lines changed

README.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,13 @@ Requires Redis 5 or greater.
88
```javascript
99
import { RedisStream } from 'redis-x-stream'
1010

11-
for await (const [stream, entry] of new RedisStream('myStream')) {
11+
for await (const [stream, [id, keyvals]] of new RedisStream('myStream')) {
1212
//process an entry
1313
}
1414
```
15-
1615
## Usage
1716

1817
See [API Docs](docs/classes/redisstream.md#constructor)
19-
20-
## TODO
21-
- [x] ~xread batch~
22-
- [x] ~xread stream~
23-
- [x] ~xread entry~
24-
- [x] ~xreadgroup entry~
25-
- [ ] xreadgroup stream
26-
- [ ] xreadgroup batch
27-
- [ ] documentation
28-
29-
## Maybe TODO
30-
- [ ] eager load?
31-
- [ ] Controller for UNBLOCK on .quit
18+
## Not yet implemented
19+
- batch mode
20+
- stream mode

docs/README.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,13 @@ Requires Redis 5 or greater.
1010
```javascript
1111
import { RedisStream } from 'redis-x-stream'
1212

13-
for await (const [stream, entry] of new RedisStream('myStream')) {
13+
for await (const [stream, [id, keyvals]] of new RedisStream('myStream')) {
1414
//process an entry
1515
}
1616
```
17-
1817
## Usage
1918

2019
See [API Docs](docs/classes/redisstream.md#constructor)
21-
22-
## TODO
23-
- [x] xread batch
24-
- [x] xread stream
25-
- [x] xread entry
26-
- [x] xreadgroup entry
27-
- [ ] xreadgroup stream
28-
- [ ] xreadgroup batch
29-
- [ ] documentation
30-
31-
## Maybe TODO
32-
- [ ] eager load?
33-
- [ ] Controller for UNBLOCK on .quit
20+
## Not yet implemented
21+
- batch mode
22+
- stream mode

docs/classes/redisstream.md

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Name | Type | Default |
2222

2323
* [ackOnIterate](redisstream.md#ackoniterate)
2424
* [block](redisstream.md#block)
25+
* [buffers](redisstream.md#buffers)
2526
* [client](redisstream.md#client)
2627
* [consumer](redisstream.md#consumer)
2728
* [count](redisstream.md#count)
28-
* [createdConnection](redisstream.md#createdconnection)
2929
* [deleteOnAck](redisstream.md#deleteonack)
3030
* [done](redisstream.md#done)
3131
* [first](redisstream.md#first)
@@ -63,65 +63,63 @@ Name | Type |
6363

6464
**Returns:** [*RedisStream*](redisstream.md)<T\>
6565

66-
Defined in: [stream.ts:58](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L58)
66+
Defined in: [stream.ts:64](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L64)
6767

6868
## Properties
6969

7070
### ackOnIterate
7171

7272
**ackOnIterate**: *boolean*= false
7373

74-
Defined in: [stream.ts:37](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L37)
74+
Defined in: [stream.ts:38](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L38)
7575

7676
___
7777

7878
### block
7979

8080
`Optional` **block**: *undefined* \| *number*
8181

82-
Defined in: [stream.ts:34](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L34)
82+
Defined in: [stream.ts:34](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L34)
83+
84+
___
85+
86+
### buffers
87+
88+
`Optional` **buffers**: *undefined* \| *boolean*= false
89+
90+
Defined in: [stream.ts:35](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L35)
8391

8492
___
8593

8694
### client
8795

8896
`Readonly` **client**: *Redis*
8997

90-
Defined in: [stream.ts:26](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L26)
98+
Defined in: [stream.ts:26](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L26)
9199

92100
___
93101

94102
### consumer
95103

96104
`Optional` `Readonly` **consumer**: *undefined* \| *string*
97105

98-
Defined in: [stream.ts:28](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L28)
106+
Defined in: [stream.ts:28](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L28)
99107

100108
___
101109

102110
### count
103111

104112
**count**: *number*= 100
105113

106-
Defined in: [stream.ts:32](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L32)
107-
108-
___
109-
110-
### createdConnection
111-
112-
`Private` **createdConnection**: *boolean*= true
113-
114-
Did we create the redis connection?
115-
116-
Defined in: [stream.ts:58](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L58)
114+
Defined in: [stream.ts:32](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L32)
117115

118116
___
119117

120118
### deleteOnAck
121119

122120
**deleteOnAck**: *boolean*= false
123121

124-
Defined in: [stream.ts:38](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L38)
122+
Defined in: [stream.ts:39](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L39)
125123

126124
___
127125

@@ -131,25 +129,23 @@ ___
131129

132130
Flag for iterable state
133131

134-
Defined in: [stream.ts:50](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L50)
132+
Defined in: [stream.ts:51](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L51)
135133

136134
___
137135

138136
### first
139137

140138
**first**: *boolean*= false
141139

142-
Flag for first iteration
143-
144-
Defined in: [stream.ts:54](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L54)
140+
Defined in: [stream.ts:52](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L52)
145141

146142
___
147143

148144
### group
149145

150146
`Optional` `Readonly` **group**: *undefined* \| *string*
151147

152-
Defined in: [stream.ts:27](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L27)
148+
Defined in: [stream.ts:27](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L27)
153149

154150
___
155151

@@ -161,15 +157,15 @@ ___
161157
'stream' mode will dispense each stream containing entries
162158
'batch' mode will dispense all streams with all entries
163159

164-
Defined in: [stream.ts:25](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L25)
160+
Defined in: [stream.ts:25](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L25)
165161

166162
___
167163

168164
### noack
169165

170166
**noack**: *boolean*= false
171167

172-
Defined in: [stream.ts:33](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L33)
168+
Defined in: [stream.ts:33](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L33)
173169

174170
___
175171

@@ -181,15 +177,15 @@ Acks waiting to be sent on either:
181177
- timeout
182178
- async iteration
183179

184-
Defined in: [stream.ts:46](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L46)
180+
Defined in: [stream.ts:47](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L47)
185181

186182
___
187183

188184
### streams
189185

190186
**streams**: *Map*<*string*, *string*\>
191187

192-
Defined in: [stream.ts:31](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L31)
188+
Defined in: [stream.ts:31](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L31)
193189

194190
## Methods
195191

@@ -199,7 +195,7 @@ Defined in: [stream.ts:31](https://github.com/calebboyd/pez/blob/557aceb/src/str
199195

200196
**Returns:** *AsyncIterator*<T *extends* *entry* ? XEntryResult : T *extends* *batch* ? XStreamResult[] : XStreamResult, *any*, *undefined*\>
201197

202-
Defined in: [stream.ts:117](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L117)
198+
Defined in: [stream.ts:127](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L127)
203199

204200
___
205201

@@ -216,7 +212,7 @@ Name | Type |
216212

217213
**Returns:** *void*
218214

219-
Defined in: [stream.ts:142](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L142)
215+
Defined in: [stream.ts:182](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L182)
220216

221217
___
222218

@@ -226,14 +222,14 @@ ___
226222

227223
**Returns:** *Promise*<*void*\>
228224

229-
Defined in: [stream.ts:131](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L131)
225+
Defined in: [stream.ts:171](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L171)
230226

231227
___
232228

233229
### return
234230

235-
`Protected`**return**(): *Promise*<*IteratorReturnResult*<*void*\>\>
231+
`Protected`**return**(): *Promise*<*void*\>
236232

237-
**Returns:** *Promise*<*IteratorReturnResult*<*void*\>\>
233+
**Returns:** *Promise*<*void*\>
238234

239-
Defined in: [stream.ts:151](https://github.com/calebboyd/pez/blob/557aceb/src/stream.ts#L151)
235+
Defined in: [stream.ts:191](https://github.com/calebboyd/pez/blob/91a6433/src/stream.ts#L191)

docs/interfaces/redisstreamoptions.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Name | Type |
1818

1919
* [ackOnIterate](redisstreamoptions.md#ackoniterate)
2020
* [block](redisstreamoptions.md#block)
21+
* [buffers](redisstreamoptions.md#buffers)
2122
* [consumer](redisstreamoptions.md#consumer)
2223
* [count](redisstreamoptions.md#count)
2324
* [deleteOnAck](redisstreamoptions.md#deleteonack)
@@ -40,7 +41,7 @@ automatically queue acknowledgments for previously iterated entries.
4041

4142
**`default`** undefined
4243

43-
Defined in: [types.ts:87](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L87)
44+
Defined in: [types.ts:98](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L98)
4445

4546
___
4647

@@ -51,7 +52,18 @@ ___
5152
The longest amount of time in milliseconds the dispenser should block
5253
while waiting for new entries on any stream, passed to xread or xreadgroup
5354

54-
Defined in: [types.ts:81](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L81)
55+
Defined in: [types.ts:92](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L92)
56+
57+
___
58+
59+
### buffers
60+
61+
`Optional` **buffers**: *undefined* \| *true*
62+
63+
Return buffers with each xread operation
64+
This applies to entry id and kv results
65+
66+
Defined in: [types.ts:81](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L81)
5567

5668
___
5769

@@ -62,7 +74,7 @@ ___
6274
The consumer.
6375
Note: if only consumer is provided, a group is created automatically
6476

65-
Defined in: [types.ts:65](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L65)
77+
Defined in: [types.ts:71](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L71)
6678

6779
___
6880

@@ -75,7 +87,7 @@ eg. the "highWaterMark"
7587

7688
**`default`** 100
7789

78-
Defined in: [types.ts:76](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L76)
90+
Defined in: [types.ts:87](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L87)
7991

8092
___
8193

@@ -88,7 +100,7 @@ automatically delete entries after acknowledgment
88100

89101
**`default`** undefined
90102

91-
Defined in: [types.ts:93](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L93)
103+
Defined in: [types.ts:104](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L104)
92104

93105
___
94106

@@ -110,7 +122,7 @@ TODO: not yet implemented
110122

111123
**`default`** 100
112124

113-
Defined in: [types.ts:113](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L113)
125+
Defined in: [types.ts:124](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L124)
114126

115127
___
116128

@@ -123,7 +135,7 @@ This counter is reset after each iteration or ack
123135

124136
TODO: not yet implemented
125137

126-
Defined in: [types.ts:120](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L120)
138+
Defined in: [types.ts:131](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L131)
127139

128140
___
129141

@@ -134,7 +146,7 @@ ___
134146
The consumer group.
135147
Note: if only a group is provided a consumer is created automatically
136148

137-
Defined in: [types.ts:60](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L60)
149+
Defined in: [types.ts:66](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L66)
138150

139151
___
140152

@@ -150,7 +162,7 @@ ___
150162

151163
**`default`** `'entry'`
152164

153-
Defined in: [types.ts:51](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L51)
165+
Defined in: [types.ts:57](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L57)
154166

155167
___
156168

@@ -162,7 +174,7 @@ Pass the NOACK flag to calls to xreadgroup bypassing the Redis PEL
162174

163175
**`default`** `false`
164176

165-
Defined in: [types.ts:98](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L98)
177+
Defined in: [types.ts:109](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L109)
166178

167179
___
168180

@@ -173,7 +185,7 @@ ___
173185
The IORedis client connection.
174186
NOTE: by default this connection becomes a "reader" when block > 0
175187

176-
Defined in: [types.ts:70](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L70)
188+
Defined in: [types.ts:76](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L76)
177189

178190
___
179191

@@ -183,4 +195,4 @@ ___
183195

184196
Redis stream keys to be read. If a Record is provided each value is the starting id for that stream
185197

186-
Defined in: [types.ts:55](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L55)
198+
Defined in: [types.ts:61](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L61)

docs/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ Renames and exports: [RedisStream](classes/redisstream.md)
4040

4141
**`default`** `'entry'`
4242

43-
Defined in: [types.ts:29](https://github.com/calebboyd/pez/blob/557aceb/src/types.ts#L29)
43+
Defined in: [types.ts:35](https://github.com/calebboyd/pez/blob/91a6433/src/types.ts#L35)

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)