npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-offline-kinesis-streams

v1.0.3

Published

A Serverless Plugin that creates local Kinesis streams and then triggers your Serverless Lambda Functions upon receiving new records.

Downloads

74

Readme

serverless-offline-kinesis-streams

A Serverless Plugin that creates local Kinesis streams and then triggers your Serverless Lambda Functions upon receiving new records.

It works depends on serverless-offline.

It works with:

  • serverless-webpack
  • serverless-typescript
  • serverless-parcel

Serverless Offline Kinesis Streams also works with multiple Kinesis streams in the same Serverless file. It respects batchWindow and batchSize. You can even listen to the same Kinesis Stream with multiple Lambda functions at once with different batchWindow and batchSize values.

Installation

Add the plugin to your project

yarn add -D serverless-offline-kinesis-streams

Then, add serverless-offline-kinesis-streams to your plugins. Example:

plugins:
  - serverless-layers
  - serverless-plugin-typescript
  - serverless-offline-kinesis-streams
  - serverless-offline

Configuration

Simple setup

custom:
  offlineKinesisStreams:
    port: 4567 # Optional; 4567 is the default port. The plugin launches a local Kinesis instance on this port
    region: local # Optional; local is the default
    streams: # Required; Define all streams and their streamNames with number of shards.
      - streamName: myFirstKinesisStream
        shards: 1

functions:
  myFirstKinesisStreamHandler:
    handler: src/myFirstKinesisStreamHandler.handler
    events:
      - stream:
          enabled: true
          type: kinesis
          arn: arn:aws:kinesis:${self:custom.region}:*:stream/myFirstKinesisStream # Same stream name from above.

Example with multiple stream:

custom:
  offlineKinesisStreams:
    port: 4567
    region: local
    streams:
      - streamName: myFirstKinesisStream
        shards: 1
      - streamName: mySecondKinesisStream
        shards: 1

functions:
  myFirstKinesisStreamHandler:
    handler: src/myFirstKinesisStreamHandler.handler
    events:
      - stream:
          enabled: true
          type: kinesis
          arn: arn:aws:kinesis:${self:custom.region}:*:stream/myFirstKinesisStream
  mySecondKinesisStreamHandler:
    handler: src/mySecondKinesisStreamHandler.handler
    events:
      - stream:
          enabled: true
          type: kinesis
          arn: arn:aws:kinesis:${self:custom.region}:*:stream/mySecondKinesisStream

Example with batchWindow and batchSize:

The example below will trigger both Lambda functions when the single Kinesis Stream has records. They are independently monitored and their batchWindow & batchSize events are individual respected.

So, when records are put into the Kinesis stream, the myFirstKinesisStreamHandler will most likely pick them up first (10 records at a time). And then, every 60 seconds, alsoListensToFirstStream will grab 1 record. (This example is contrived. You'd never want such a high batchWindow and low batchSize.)

custom:
  offlineKinesisStreams:
    port: 4567
    region: local
    streams:
      - streamName: myFirstKinesisStream
        shards: 1

functions:
  myFirstKinesisStreamHandler:
    handler: src/myFirstKinesisStreamHandler.handler
    events:
      - stream:
          enabled: true
          type: kinesis
          arn: arn:aws:kinesis:${self:custom.region}:*:stream/myFirstKinesisStream
  alsoListensToFirstStream:
    handler: src/mySecondKinesisStreamHandler.handler
    events:
      - stream:
          enabled: true
          type: kinesis
          batchWindow: 60 # Get records every 60 seconds
          batchSize: 1 # Get one record at a time
          arn: arn:aws:kinesis:${self:custom.region}:*:stream/myFirstKinesisStream

Thanks

Features were extended off of this implementation of a local Kinesis

Thanks to mhart for creating kinesalite