Giter Site home page Giter Site logo

kinesis-console-consumer's Introduction

Kinesis Console Consumer

Build Status npm version Coverage Status

The Kafka quickstart demos a simple consumer so you can quickly inspect your Kafka stream. Unfortunately, there is no equivalent for AWS Kinesis...

Until now.

Usage

npm install [-g] kinesis-console-consumer

kinesis-console-consumer <stream_name>

Help

$ kinesis-console-consumer --help

  Usage: kinesis-console-consumer [options] <stream_name>

  Options:

    -h, --help                      output usage information
    -V, --version                   output the version number
    --type-latest                   (DEFAULT) start reading any new data (LATEST)
    --type-oldest                   start reading from the oldest data (TRIM_HORIZON)
    --type-at <sequence_number>     start reading from this sequence number (AT_SEQUENCE_NUMBER)
    --type-after <sequence_number>  start reading after this sequence number (AFTER_SEQUENCE_NUMBER)
    --type-timestamp <timestamp>    start reading after this time (units: epoch seconds) (AT_TIMESTAMP)
    --new-line                      print each record to a new line
    --regex-filter <regexFilter>    filter data using this regular expression

Examples

List Kinesis streams:

kinesis-console-consumer

Display contents of a stream, "hello-world", starting from 15 minutes ago:

kinesis-console-consumer 'hello-world' --type-timestamp "$(($(date +%s) - 900))"

Usage as a package

You can import this module into your own project to use as Kinesis Stream Reader readable stream too!

const AWS = require('aws-sdk')
const { KinesisStreamReader } = require('kinesis-console-consumer')
const client = AWS.Kinesis()
const reader = new KinesisStreamReader(client, streamName, options)
reader.pipe(yourDestinationHere)

Options

  • interval: number (default: 2000) Milliseconds between each Kinesis read. Remember limit is 5 reads / second / shard

  • parser: Function If this is set, this function is applied to the data. Example:

      const client = AWS.Kinesis()
      const reader = new KinesisStreamReader(client, streamName, {parser: JSON.parse})
      reader.on('data', console.log(data.id))
    
  • And any getShardIterator parameter

Custom events

These are the WIP events you can attach to the reader:

  • checkpoint Inspired by kinesis-readable, this fires when data is received so you can keep track of the last successful sequence read

      reader.on('checkpoint', (sequenceNumber: string) => {})
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.