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

mutator-io-plugin-out-dynamodb

v0.1.7

Published

Output stream plugin for mutator-io to interface with DynamoDB

Downloads

2

Readme

DynamoDB output stream

NPM version

DynamoDB output stream aims to cover as many operations possible via aws sdk DynamoDB module to be used with mutator-io.

Installation

npm i mutator-io-plugin-out-dynamodb

Ideally this should leverage Rx.js to perform fail-safe operations like batchWriteItem. This means that we can hide the whole logic of retrying failed calls (e.g. consuming UnprocessedItems returned from the standard BatchWriteItem call untill all of them are written)

The configuration required is exactly the same of the original sdk.

There's an extra custom parameter called IGNORE_ERRORS which is a list of error codes (and optionally message) that we might want to ignore to avoid bloating the logs.

Here's an example:

new DynamoDB({
  IGNORE_ERRORS: [
    { code: 'ConditionalCheckFailedException' },
    { code: 'ValidationException', message: 'specific validation message' }
  ]
} as DynamoDB.Config)

The create method returns a function that accepts a custom Message type parameter.

enum Operations {
  PUT = 'put',
  DELETE = 'delete'
  UPDATE = 'update'
}

interface RetryDelay {
  (msg: any): Observable<number>
}

interface Message {
  operation: Operations
  params: Object
  retry?: number
  retryDelay?: RetryDelay
}

As long as the transformation returns an object shaped this way, this output stream will perform one of the Operations specified in the DynamoDB instance and will return the same message we've sent in the output if it succeeds (or fire the stream's error callback)

Transformation example:

import * as DynamoDBOutputStream from 'mutator-io-plugin-out-dynamodb'

mutatorIOInstance.transform('myPipeName', (msg): DynamoDBOutputStream.Message => {
  const params = {
    TableName : 'test_table',
    Item: {
      id: msg.payload,
      NumAttribute: 1,
      BoolAttribute: true,
      ListAttribute: [1, 'two', false],
      MapAttribute: { foo: 'bar'},
      NullAttribute: null
    }
  }

  return {
    operation: outputStreams.DynamoDB.Operations.PUT,
    params
  }
})

You can optionally specify a retry parameter, which will make the output stream retry the write operation N times in case of failure. retrDelay optional parameter should be a function returning an observable (e.g. (msg) => Rx.Observable.of(2000)) - this will be called every time an error comes in, allowing the user to set dynamic delays between retries (e.g. based on something in the message, or perform more complex async operations to determine the delay to apply)

Typescript documentation