presidium 0.15.29 → 0.15.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/KinesisStream.js +1 -14
- package/KinesisStream.test.js +17 -0
- package/package.json +1 -1
package/KinesisStream.js
CHANGED
|
@@ -29,11 +29,6 @@ const {
|
|
|
29
29
|
* endpoint: string,
|
|
30
30
|
* shardIteratorType: 'AT_SEQUENCE_NUMBER'|'AFTER_SEQUENCE_NUMBER'|'TRIM_HORIZON'|'LATEST'|'AT_TIMESTAMP',
|
|
31
31
|
* timestamp: Date|string|number, // find events at date (requires shardIteratorType 'AT_TIMESTAMP')
|
|
32
|
-
* startingSequenceNumber: string, // find events at data record (requires shardIteratorType 'AT_SEQUENCE_NUMBER' or 'AFTER_SEQUENCE_NUMBER')
|
|
33
|
-
* shardFilterType: 'AFTER_SHARD_ID'|'AT_TRIM_HORIZON'|'FROM_TRIM_HORIZON'|'AT_LATEST'|'AT_TIMESTAMP'|'FROM_TIMESTAMP',
|
|
34
|
-
* shardFilterShardId: string,
|
|
35
|
-
* shardFilterTimestamp: Date|string|number,
|
|
36
|
-
* streamCreationTimestamp: Date|string|number, // distinguishes streams of same name e.g. after deleting
|
|
37
32
|
* }) -> KinesisStream
|
|
38
33
|
* ```
|
|
39
34
|
*
|
|
@@ -53,13 +48,7 @@ const KinesisStream = function (options) {
|
|
|
53
48
|
this.shardUpdatePeriod = options.shardUpdatePeriod ?? 15000
|
|
54
49
|
this.getRecordsInterval = options.getRecordsInterval ?? 1000
|
|
55
50
|
this.shardIteratorType = options.shardIteratorType ?? 'LATEST'
|
|
56
|
-
this.shardIteratorTimestamp = options.shardIteratorTimestamp
|
|
57
|
-
this.shardFilterType = options.shardFilterType
|
|
58
|
-
this.shardFilterShardId = options.shardFilterShardId
|
|
59
|
-
this.shardFilterTimestamp = options.shardFilterTimestamp
|
|
60
|
-
this.streamCreationTimestamp = options.streamCreationTimestamp
|
|
61
51
|
this.timestamp = options.timestamp
|
|
62
|
-
this.startingSequenceNumber = options.startingSequenceNumber
|
|
63
52
|
this.kinesis = new Kinesis(omit(['name'])(options))
|
|
64
53
|
this.cancelToken = new Promise((_, reject) => (this.canceller = reject))
|
|
65
54
|
|
|
@@ -163,9 +152,7 @@ KinesisStream.prototype.getRecords = async function* getRecords(Shard) {
|
|
|
163
152
|
ShardId: Shard.ShardId,
|
|
164
153
|
StreamName: this.name,
|
|
165
154
|
ShardIteratorType: this.shardIteratorType,
|
|
166
|
-
...this.
|
|
167
|
-
Timestamp: this.shardIteratorTimestamp,
|
|
168
|
-
},
|
|
155
|
+
...this.timestamp == null ? {} : { Timestamp: this.timestamp },
|
|
169
156
|
}).promise().then(get('ShardIterator'))
|
|
170
157
|
|
|
171
158
|
let records = await this.kinesis.client.getRecords({
|
package/KinesisStream.test.js
CHANGED
|
@@ -7,9 +7,11 @@ const map = require('rubico/map')
|
|
|
7
7
|
const thunkify = require('rubico/thunkify')
|
|
8
8
|
|
|
9
9
|
const test = new Test('KinesisStream', KinesisStream)
|
|
10
|
+
|
|
10
11
|
.before(function () {
|
|
11
12
|
this.streams = []
|
|
12
13
|
})
|
|
14
|
+
|
|
13
15
|
.case({
|
|
14
16
|
name: 'my-stream',
|
|
15
17
|
endpoint: 'http://localhost:4567',
|
|
@@ -21,7 +23,22 @@ const test = new Test('KinesisStream', KinesisStream)
|
|
|
21
23
|
await myStream.putRecord('hey')
|
|
22
24
|
await myStream.putRecord('ho', { partitionKey: 'ho' })
|
|
23
25
|
await myStream.putRecord('hi', { explicitHashKey: '127' })
|
|
26
|
+
const first3 = await asyncIterableTake(3)(myStream)
|
|
27
|
+
const first3Again = await asyncIterableTake(3)(myStream)
|
|
28
|
+
assert.deepEqual(first3, first3Again)
|
|
29
|
+
this.streams.push(myStream)
|
|
30
|
+
})
|
|
24
31
|
|
|
32
|
+
.case({
|
|
33
|
+
name: 'my-stream',
|
|
34
|
+
endpoint: 'http://localhost:4567',
|
|
35
|
+
shardIteratorType: 'AT_TIMESTAMP',
|
|
36
|
+
timestamp: new Date(Date.now() - 5000),
|
|
37
|
+
}, async function (myStream) {
|
|
38
|
+
await myStream.ready
|
|
39
|
+
await myStream.putRecord('hey')
|
|
40
|
+
await myStream.putRecord('ho', { partitionKey: 'ho' })
|
|
41
|
+
await myStream.putRecord('hi', { explicitHashKey: '127' })
|
|
25
42
|
const first3 = await asyncIterableTake(3)(myStream)
|
|
26
43
|
const first3Again = await asyncIterableTake(3)(myStream)
|
|
27
44
|
assert.deepEqual(first3, first3Again)
|