Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lifion-kinesis

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lifion-kinesis

Lifion client for Amazon Kinesis Data streams

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2K
increased by10.09%
Maintainers
3
Weekly downloads
 
Created
Source

lifion-kinesis

Lifion's Node.js client for Amazon Kinesis Data Streams.

Getting Started

To install the module:

npm install lifion-kinesis --save

The main module export is a Kinesis class that instantiates as a readable stream.

const Kinesis = require('lifion-kinesis');

const client = new Kinesis({
  streamName: 'sample-stream',
  consumerName: 'sample-consumer'
  /* other options from AWS.Kinesis */
});
client.on('data', chunk => {
  console.log('Incoming data:', chunk);
});

To take advantage of back-pressure, the client can be piped to a writable stream:

const Kinesis = require('lifion-kinesis');
const { pipeline } = require('stream');

pipeline([
  new Kinesis(/* options */),
  new Writable({
    objectMode: true,
    write(data, encoding, callback) {
      console.log(data);
      callback();
    }
  })
]);

Features

  • Standard Node.js stream abstraction of Kinesis streams.
  • Node.js implementation of the new enhanced fan-out feature.
  • Optional auto-creation, encryption, and tagging of Kinesis streams.

Incoming Features:

  • Support for a polling mode, using the GetRecords API, with automatic checkpointing.
  • Support for multiple concurrent consumers through automatic assignment of shards.
  • Support for sending messages to streams, with auto-retries.

API Reference

Kinesis ⇐ Readable

A specialization of the readable stream class implementing a consumer of Kinesis Data Streams using the enhanced fan-out feature. Upon connection, instances of this class will subscribe to receive data from all the shards of the given stream. Incoming data can be retrieved through either the data event or by piping the instance to a writable stream.

Kind: Exported class
Extends: Readable

new Kinesis(options)

Initializes a new instance of the Kinesis client.

ParamTypeDefaultDescription
optionsObjectThe initialization options. In addition to the below options, this object can also contain the AWS.Kinesis options.
[options.compression]stringThe kind of data compression to use with records. The currently available compression options are either "LZ-UTF8" or none.
options.consumerNamestringThe unique name of the consumer for the given stream. This option is required.
[options.createStreamIfNeeded]booleanfalseWhether if the Kinesis stream should be created if it doesn't exist upon connection.
[options.compression]ObjectThe kind of compression to enforce in the stream.
[options.compression.type]stringThe encryption type to use.
[options.compression.keyId]stringThe GUID for the customer-managed AWS KMS key to use for encryption. This value can be a globally unique identifier, a fully specified ARN to either an alias or a key, or an alias name prefixed by "alias/".
[options.logger]ObjectAn object with the warn, debug, and error functions that will be used for logging purposes. If not provided, logging will be omitted.
[options.shardCount]number1The number of shards that the newly-created stream will use (if the createStreamIfNeeded option is set).
options.streamNamestringThe name of the stream to consume data from. This option is required.
[options.tags]ObjectIf provided, the client will ensure that the stream is tagged with these hash of tags upon connection. If the stream is already tagged same tag keys, they won't be overriden. If the stream is already tagged with different tag keys, they won't be removed.

kinesis.connect() ⇒ Promise

Initializes the Kinesis client, then it proceeds to:

  1. Create the stream if asked for.
  2. Ensure that the stream is active.
  3. Ensure that the stream is encrypted as indicated.
  4. Ensure that the stream is tagged as requested.
  5. Ensure an enhanced fan-out consumer with the given name exists.
  6. Ensure that the enhanced fan-out consumer is active.
  7. A subscription for data is issued to all the shard in the stream.
  8. Data will then be available in both stream read modes.

Kind: instance method of Kinesis
Fulfil: Once the stream is active, encrypted, tagged, the enhanced fan-out consumer is active, and the client is subscribed to the data in all the stream shards.
Reject: Error - If at least one of the above steps fails to succeed.

License

MIT

Keywords

FAQs

Package last updated on 29 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc