Skip to content

Commit

Permalink
feat: remove mode generic
Browse files Browse the repository at this point in the history
  • Loading branch information
calebboyd committed Nov 19, 2022
1 parent 2ca6a5a commit 16434bc
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 235 deletions.
8 changes: 2 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ Requires Redis 5 or greater.
## Getting Started

```javascript
import streamEntries from 'redis-x-stream'
import stream from 'redis-x-stream'

for await (const [stream, [id, keyvals]] of streamEntries('myStream')) {
for await (const [streamName, [id, keyvals]] of stream('myStream')) {
//process an entry
}
```
## Usage

See [API Docs](docs/classes/redisstream.md#constructor)

## Not yet implemented
- batch mode
- stream mode
81 changes: 29 additions & 52 deletions docs/classes/redisstream.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[redis-x-stream](../README.md) / [Exports](../modules.md) / RedisStream

# Class: RedisStream<T\>

## Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends [`Mode`](../modules.md#mode) = ``"entry"`` |
# Class: RedisStream

## Table of contents

Expand All @@ -26,7 +20,6 @@
- [done](RedisStream.md#done)
- [first](RedisStream.md#first)
- [group](RedisStream.md#group)
- [mode](RedisStream.md#mode)
- [noack](RedisStream.md#noack)
- [pendingAcks](RedisStream.md#pendingacks)
- [streams](RedisStream.md#streams)
Expand All @@ -42,24 +35,18 @@

### constructor

**new RedisStream**<`T`\>(`options`, ...`streams`)

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends [`Mode`](../modules.md#mode) = ``"entry"`` |
**new RedisStream**(`options`, ...`streams`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | `string` \| [`RedisStreamOptions`](../interfaces/RedisStreamOptions.md)<`T`\> |
| `options` | `string` \| [`RedisStreamOptions`](../interfaces/RedisStreamOptions.md) |
| `...streams` | `string`[] |

#### Defined in

[stream.ts:63](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L63)
[stream.ts:63](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L63)

## Properties

Expand All @@ -69,7 +56,7 @@

#### Defined in

[stream.ts:35](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L35)
[stream.ts:35](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L35)

___

Expand All @@ -79,7 +66,7 @@ ___

#### Defined in

[stream.ts:31](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L31)
[stream.ts:31](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L31)

___

Expand All @@ -89,17 +76,21 @@ ___

#### Defined in

[stream.ts:32](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L32)
[stream.ts:32](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L32)

___

### client

`Readonly` **client**: `Redis`

'entry' mode will dispense each entry of each stream
'stream' mode will dispense each stream containing entries
'batch' mode will dispense all streams with all entries

#### Defined in

[stream.ts:23](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L23)
[stream.ts:23](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L23)

___

Expand All @@ -109,7 +100,7 @@ ___

#### Defined in

[stream.ts:25](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L25)
[stream.ts:25](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L25)

___

Expand All @@ -119,7 +110,7 @@ ___

#### Defined in

[stream.ts:29](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L29)
[stream.ts:29](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L29)

___

Expand All @@ -129,7 +120,7 @@ ___

#### Defined in

[stream.ts:36](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L36)
[stream.ts:36](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L36)

___

Expand All @@ -141,7 +132,7 @@ Flag for iterable state

#### Defined in

[stream.ts:48](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L48)
[stream.ts:48](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L48)

___

Expand All @@ -151,7 +142,7 @@ ___

#### Defined in

[stream.ts:49](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L49)
[stream.ts:49](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L49)

___

Expand All @@ -161,21 +152,7 @@ ___

#### Defined in

[stream.ts:24](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L24)

___

### mode

`Readonly` **mode**: [`Mode`](../modules.md#mode) = `'entry'`

'entry' mode will dispense each entry of each stream
'stream' mode will dispense each stream containing entries
'batch' mode will dispense all streams with all entries

#### Defined in

[stream.ts:22](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L22)
[stream.ts:24](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L24)

___

Expand All @@ -185,7 +162,7 @@ ___

#### Defined in

[stream.ts:30](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L30)
[stream.ts:30](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L30)

___

Expand All @@ -199,7 +176,7 @@ Acks waiting to be sent on either:

#### Defined in

[stream.ts:44](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L44)
[stream.ts:44](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L44)

___

Expand All @@ -209,27 +186,27 @@ ___

#### Defined in

[stream.ts:28](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L28)
[stream.ts:28](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L28)

## Methods

### [asyncIterator]

**[asyncIterator]**(): `AsyncIterator`<`T` extends ``"entry"`` ? `XEntryResult` : `T` extends ``"batch"`` ? `XStreamResult`[] : `XStreamResult`, `any`, `undefined`\>
**[asyncIterator]**(): `AsyncIterator`<`XEntryResult`, `any`, `undefined`\>

#### Returns

`AsyncIterator`<`T` extends ``"entry"`` ? `XEntryResult` : `T` extends ``"batch"`` ? `XStreamResult`[] : `XStreamResult`, `any`, `undefined`\>
`AsyncIterator`<`XEntryResult`, `any`, `undefined`\>

#### Defined in

[stream.ts:124](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L124)
[stream.ts:128](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L128)

___

### ack

**ack**(`stream`, ...`ids`): `void`
**ack**(`stream`, ...`ids`): `undefined`

#### Parameters

Expand All @@ -240,11 +217,11 @@ ___

#### Returns

`void`
`undefined`

#### Defined in

[stream.ts:179](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L179)
[stream.ts:185](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L185)

___

Expand All @@ -258,7 +235,7 @@ ___

#### Defined in

[stream.ts:168](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L168)
[stream.ts:174](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L174)

___

Expand All @@ -272,4 +249,4 @@ ___

#### Defined in

[stream.ts:188](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/stream.ts#L188)
[stream.ts:195](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/stream.ts#L195)
51 changes: 12 additions & 39 deletions docs/interfaces/redisstreamoptions.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[redis-x-stream](../README.md) / [Exports](../modules.md) / RedisStreamOptions

# Interface: RedisStreamOptions<T\>

## Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends [`Mode`](../modules.md#mode) |
# Interface: RedisStreamOptions

## Table of contents

Expand All @@ -20,7 +14,6 @@
- [deleteOnAck](RedisStreamOptions.md#deleteonack)
- [flushPendingAckInterval](RedisStreamOptions.md#flushpendingackinterval)
- [group](RedisStreamOptions.md#group)
- [mode](RedisStreamOptions.md#mode)
- [noack](RedisStreamOptions.md#noack)
- [redis](RedisStreamOptions.md#redis)
- [streams](RedisStreamOptions.md#streams)
Expand All @@ -40,7 +33,7 @@ false

#### Defined in

[types.ts:98](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L98)
[types.ts:71](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L71)

___

Expand All @@ -53,7 +46,7 @@ while waiting for new entries on any stream, passed to xread or xreadgroup

#### Defined in

[types.ts:92](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L92)
[types.ts:65](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L65)

___

Expand All @@ -66,7 +59,7 @@ This applies to entry id and kv results

#### Defined in

[types.ts:81](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L81)
[types.ts:54](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L54)

___

Expand All @@ -79,7 +72,7 @@ Note: if only consumer is provided, a group is created automatically

#### Defined in

[types.ts:71](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L71)
[types.ts:44](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L44)

___

Expand All @@ -96,7 +89,7 @@ eg. the "highWaterMark"

#### Defined in

[types.ts:87](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L87)
[types.ts:60](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L60)

___

Expand All @@ -113,7 +106,7 @@ false

#### Defined in

[types.ts:104](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L104)
[types.ts:77](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L77)

___

Expand All @@ -128,7 +121,7 @@ TODO: not yet implemented

#### Defined in

[types.ts:116](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L116)
[types.ts:89](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L89)

___

Expand All @@ -141,27 +134,7 @@ Note: if only a group is provided a consumer is created automatically

#### Defined in

[types.ts:66](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L66)

___

### mode

`Optional` **mode**: `T`

`'entry'` mode is default and will iterate over each stream entry in each stream in the result set

`'stream'` mode will iterate over each XREAD[GROUP] stream result

`'batch'` mode will iterate over each XREAD[GROUP] call result

**`Default`**

`'entry'`

#### Defined in

[types.ts:57](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L57)
[types.ts:39](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L39)

___

Expand All @@ -177,7 +150,7 @@ false

#### Defined in

[types.ts:109](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L109)
[types.ts:82](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L82)

___

Expand All @@ -190,7 +163,7 @@ NOTE: by default this connection becomes a "reader" when block > 0

#### Defined in

[types.ts:76](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L76)
[types.ts:49](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L49)

___

Expand All @@ -202,4 +175,4 @@ Redis stream keys to be read. If a Record is provided each value is the starting

#### Defined in

[types.ts:61](https://github.com/calebboyd/redis-x-stream/blob/b5db328/src/types.ts#L61)
[types.ts:34](https://github.com/calebboyd/redis-x-stream/blob/2ca6a5a/src/types.ts#L34)
Loading

0 comments on commit 16434bc

Please sign in to comment.