presidium 0.15.23 → 0.15.29

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/DynamoStream.js CHANGED
@@ -144,17 +144,19 @@ DynamoStream.prototype.getRecords = async function* getRecords(
144
144
  */
145
145
 
146
146
  }).promise().then(get('ShardIterator'))
147
+
147
148
  let records = await this.client.getRecords({
148
149
  ShardIterator: startingShardIterator,
149
150
  Limit: this.getRecordsLimit
150
151
  }).promise()
151
-
152
152
  if (records.Records.length > 0) {
153
153
  yield* records.Records.map(assign({
154
154
  table: always(this.table),
155
155
  shardId: always(Shard.ShardId),
156
156
  }))
157
157
  }
158
+ await new Promise(resolve => setTimeout(resolve, this.getRecordsInterval))
159
+
158
160
  while (!this.closed && records.NextShardIterator != null) {
159
161
  records = await this.client.getRecords({
160
162
  ShardIterator: records.NextShardIterator,
package/KinesisStream.js CHANGED
@@ -116,7 +116,6 @@ KinesisStream.prototype.delete = function deleteStream() {
116
116
  * ```
117
117
  */
118
118
  KinesisStream.prototype.putRecord = async function putRecord(data, options = {}) {
119
- await this.ready
120
119
  return this.kinesis.client.putRecord({
121
120
  StreamName: this.name,
122
121
  Data: data,
@@ -142,14 +141,19 @@ KinesisStream.prototype.listShards = async function* listShards() {
142
141
  StreamName: this.name,
143
142
  MaxResults: this.listShardsLimit,
144
143
  }).promise()
145
- yield* shards.Shards
144
+ if (shards.Shards.length > 0) {
145
+ yield* shards.Shards
146
+ }
147
+
146
148
  while (!this.closed && shards.NextToken != null) {
147
149
  shards = await this.kinesis.client.listShards({
148
150
  StreamName: this.name,
149
151
  MaxResults: this.listShardsLimit,
150
152
  NextToken: shards.NextToken,
151
153
  })
152
- yield* shards.Shards
154
+ if (shards.Shards.length > 0) {
155
+ yield* shards.Shards
156
+ }
153
157
  }
154
158
  }
155
159
 
@@ -163,19 +167,25 @@ KinesisStream.prototype.getRecords = async function* getRecords(Shard) {
163
167
  Timestamp: this.shardIteratorTimestamp,
164
168
  },
165
169
  }).promise().then(get('ShardIterator'))
170
+
166
171
  let records = await this.kinesis.client.getRecords({
167
172
  ShardIterator: startingShardIterator,
168
173
  Limit: this.getRecordsLimit,
169
174
  }).promise()
175
+ if (records.Records.length > 0) {
176
+ yield* records.Records
177
+ }
170
178
  await new Promise(resolve => setTimeout(resolve, this.getRecordsInterval))
171
- yield* records.Records
179
+
172
180
  while (!this.closed && records.NextShardIterator != null) {
173
181
  records = await this.kinesis.client.getRecords({
174
182
  ShardIterator: records.NextShardIterator,
175
183
  Limit: this.getRecordsLimit,
176
184
  }).promise()
185
+ if (records.Records.length > 0) {
186
+ yield* records.Records
187
+ }
177
188
  await new Promise(resolve => setTimeout(resolve, this.getRecordsInterval))
178
- yield* records.Records
179
189
  }
180
190
  }
181
191
 
@@ -186,11 +196,13 @@ KinesisStream.prototype[Symbol.asyncIterator] = async function* generateRecords(
186
196
  let muxAsyncIterator = Mux.race([
187
197
  ...shards.map(Shard => this.getRecords(Shard)),
188
198
  (async function* UpdateShardsGenerator() {
189
- while (true) {
199
+ while (!this.closed) {
190
200
  await new Promise(resolve => {
191
201
  setTimeout(resolve, this.shardUpdatePeriod)
192
202
  })
193
- yield SymbolUpdateShards
203
+ if (!this.closed) {
204
+ yield SymbolUpdateShards
205
+ }
194
206
  }
195
207
  }).call(this),
196
208
  ])
@@ -65,6 +65,8 @@ const test = new Test('KinesisStream', KinesisStream)
65
65
  // wait a second for shard update
66
66
  await new Promise(resolve => setTimeout(thunkify(resolve, 'hey'), 1000))
67
67
  myStream.close()
68
+ // ensure shards don't update after close
69
+ await new Promise(resolve => setTimeout(resolve, 1000))
68
70
  })
69
71
 
70
72
  .after(async function() {
@@ -177,6 +177,10 @@ TranscribeStream.prototype.sendAudioChunk = function (chunk) {
177
177
  this.websocket.send(bytes)
178
178
  }
179
179
 
180
+ TranscribeStream.prototype.close = function () {
181
+ this.websocket.close()
182
+ }
183
+
180
184
  /**
181
185
  * @name marshalHeaders
182
186
  *
@@ -53,7 +53,7 @@ const test = new Test('TranscribeStream', async function () {
53
53
  wav.fromMuLaw()
54
54
  testTranscribeStream.sendAudioChunk(Buffer.from(wav.data.samples))
55
55
  } else if (event.event == 'stop') {
56
- testTranscribeStream.websocket.close()
56
+ testTranscribeStream.close()
57
57
  }
58
58
  })
59
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.15.23",
3
+ "version": "0.15.29",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",