lifion-kinesis
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -10,2 +10,11 @@ ## Changelog | ||
### v1.1.2 (2019-10-18) | ||
- [`#245`](https://github.com/lifion/lifion-kinesis/pull/245): expose the list shards method | ||
- [`#232`](https://github.com/lifion/lifion-kinesis/pull/232): Update dependency aws-sdk to ^2.535.0 | ||
- [`#234`](https://github.com/lifion/lifion-kinesis/pull/234): Update dependency codecov to ^3.6.1 | ||
- [`#235`](https://github.com/lifion/lifion-kinesis/pull/235): Update dependency lint-staged to ^9.3.0 | ||
- [`#233`](https://github.com/lifion/lifion-kinesis/pull/233): Update dependency eslint to ^6.4.0 | ||
- [`750240b`](https://github.com/lifion/lifion-kinesis/commit/750240bcd89931279623eedc1401c7d33324a99b): Upgrade dependencies and fix new linter exceptions | ||
### v1.1.1 (2019-09-11) | ||
@@ -12,0 +21,0 @@ |
@@ -158,2 +158,20 @@ /** | ||
function parsePutRecordResult({ EncryptionType, SequenceNumber, ShardId }) { | ||
return { | ||
encryptionType: EncryptionType, | ||
sequenceNumber: SequenceNumber, | ||
shardId: ShardId | ||
}; | ||
} | ||
function parsePutRecordsResult({ EncryptionType, Records }) { | ||
return { | ||
encryptionType: EncryptionType, | ||
records: Records.map(({ SequenceNumber, ShardId }) => ({ | ||
sequenceNumber: SequenceNumber, | ||
shardId: ShardId | ||
})) | ||
}; | ||
} | ||
/** | ||
@@ -423,9 +441,4 @@ * A [pass-through stream]{@link external:PassThrough} class specialization implementing a consumer | ||
}; | ||
const parseResult = ({ EncryptionType, SequenceNumber, ShardId }) => ({ | ||
encryptionType: EncryptionType, | ||
sequenceNumber: SequenceNumber, | ||
shardId: ShardId | ||
}); | ||
try { | ||
return parseResult(await client.putRecord(awsParams)); | ||
return parsePutRecordResult(await client.putRecord(awsParams)); | ||
} catch (err) { | ||
@@ -438,3 +451,3 @@ const { code } = err; | ||
await ensureStreamInitialized(this, streamName); | ||
return parseResult(await client.putRecord(awsParams)); | ||
return parsePutRecordResult(await client.putRecord(awsParams)); | ||
} | ||
@@ -446,2 +459,35 @@ throw err; | ||
/** | ||
* List the shards of a stream. | ||
* | ||
* @param {object} params - The parameters. | ||
* @param {string} [params.streamName] - If provided, the method will list the shards of the | ||
* specific stream instead of the stream name provided during the consumer instantiation. | ||
* @fulfil {Object} - The de-serialized data returned from the request. | ||
* @reject {Error} - On any unexpected error while writing to the stream. | ||
* @returns {Promise} | ||
*/ | ||
async listShards(params = {}) { | ||
const privateProps = internal(this); | ||
const { client } = privateProps; | ||
const { streamName } = params; | ||
const awsParams = { | ||
StreamName: streamName || privateProps.streamName | ||
}; | ||
const { Shards } = await client.listShards(awsParams); | ||
return Shards.map( | ||
({ | ||
HashKeyRange: { EndingHashKey, StartingHashKey }, | ||
SequenceNumberRange: { StartingSequenceNumber }, | ||
ShardId | ||
}) => ({ | ||
hashKeyRange: { endingHashKey: EndingHashKey, startingHashKey: StartingHashKey }, | ||
sequenceNumberRange: { startingSequenceNumber: StartingSequenceNumber }, | ||
shardId: ShardId | ||
}) | ||
); | ||
} | ||
/** | ||
* Writes multiple data records into a stream in a single call. | ||
@@ -477,11 +523,4 @@ * | ||
}; | ||
const parseResult = ({ EncryptionType, Records }) => ({ | ||
encryptionType: EncryptionType, | ||
records: Records.map(({ SequenceNumber, ShardId }) => ({ | ||
sequenceNumber: SequenceNumber, | ||
shardId: ShardId | ||
})) | ||
}); | ||
try { | ||
return parseResult(await client.putRecords(awsParams)); | ||
return parsePutRecordsResult(await client.putRecords(awsParams)); | ||
} catch (err) { | ||
@@ -494,3 +533,3 @@ const { code } = err; | ||
await ensureStreamInitialized(this, streamName); | ||
return parseResult(await client.putRecords(awsParams)); | ||
return parsePutRecordsResult(await client.putRecords(awsParams)); | ||
} | ||
@@ -497,0 +536,0 @@ throw err; |
@@ -44,3 +44,3 @@ /** | ||
const newLineIndex = newStack.indexOf('\n'); | ||
const stack = `${code}: ${message}${newStack.substr(newLineIndex)}`; | ||
const stack = `${code}: ${message}${newStack.slice(newLineIndex)}`; | ||
return Object.assign( | ||
@@ -47,0 +47,0 @@ error, |
{ | ||
"name": "lifion-kinesis", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Lifion client for Amazon Kinesis Data streams", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
"async-retry": "^1.2.3", | ||
"aws-sdk": "^2.527.0", | ||
"aws-sdk": "^2.553.0", | ||
"aws4": "^1.8.0", | ||
@@ -58,3 +58,3 @@ "fast-deep-equal": "^2.0.1", | ||
"is-retry-allowed": "^1.2.0", | ||
"lifion-aws-event-stream": "^1.0.5", | ||
"lifion-aws-event-stream": "^1.0.6", | ||
"lru-cache": "^5.1.1", | ||
@@ -68,11 +68,11 @@ "lzutf8": "^0.5.5", | ||
"chalk": "^2.4.2", | ||
"chance": "^1.1.0", | ||
"chance": "^1.1.3", | ||
"check-engines": "^1.5.0", | ||
"codecov": "^3.5.0", | ||
"eslint": "^6.3.0", | ||
"eslint-config-lifion": "^1.3.0", | ||
"husky": "^3.0.5", | ||
"codecov": "^3.6.1", | ||
"eslint": "^6.5.1", | ||
"eslint-config-lifion": "^1.3.2", | ||
"husky": "^3.0.9", | ||
"jest": "^24.9.0", | ||
"jsdoc-to-markdown": "^5.0.1", | ||
"lint-staged": "^9.2.5", | ||
"jsdoc-to-markdown": "^5.0.2", | ||
"lint-staged": "^9.4.2", | ||
"npm-watch": "^0.6.0", | ||
@@ -79,0 +79,0 @@ "prettier": "^1.18.2", |
@@ -66,2 +66,3 @@ # lifion-kinesis | ||
- [.putRecord(params)](#module_lifion-kinesis--Kinesis+putRecord) ⇒ <code>Promise</code> | ||
- [.listShards(params)](#module_lifion-kinesis--Kinesis+listShards) ⇒ <code>Promise</code> | ||
- [.putRecords(params)](#module_lifion-kinesis--Kinesis+putRecords) ⇒ <code>Promise</code> | ||
@@ -156,2 +157,17 @@ - [.getStats()](#module_lifion-kinesis--Kinesis+getStats) ⇒ <code>object</code> | ||
<a name="module_lifion-kinesis--Kinesis+listShards"></a> | ||
#### kinesis.listShards(params) ⇒ <code>Promise</code> | ||
List the shards of a stream. | ||
**Kind**: instance method of [<code>Kinesis</code>](#exp_module_lifion-kinesis--Kinesis) | ||
**Fulfil**: <code>Object</code> - The de-serialized data returned from the request. | ||
**Reject**: <code>Error</code> - On any unexpected error while writing to the stream. | ||
| Param | Type | Description | | ||
| ------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| params | <code>object</code> | The parameters. | | ||
| [params.streamName] | <code>string</code> | If provided, the method will list the shards of the specific stream instead of the stream name provided during the consumer instantiation. | | ||
<a name="module_lifion-kinesis--Kinesis+putRecords"></a> | ||
@@ -158,0 +174,0 @@ |
232789
4490
210
Updatedaws-sdk@^2.553.0