dynamodb-eventstore

Store events in AWS DynamoDB

npm install dynamodb-eventstore
1 downloads in the last week
4 downloads in the last month

dynamodb-eventstore

Stability: 1 - Experimental

NPM version

Store events in DynamoDb.

Installation

npm install dynamodb-eventstore

Tests

Unit Tests

npm test

Integration "sanity check" Test

npm run-script integration

Given DYNAMODB_ES_TEST_ACCESS_KEY_ID and DYNAMODB_ES_TEST_SECRET_ACCESS_KEY are present in the environment, will attempt to insert {foo: "bar"} into the event store. If an error occurs, result will be:

error
done

On success, result will be:

done

Overview

DynamoDbEventStore is a simple client to store events in a DynamoDb table. It turns a JavaScript object into JSON and stores it under a unique key related to client time.

var DynamoDbEventStore = require('dynamodb-eventstore');
var es = new DynamoDbEventStore({
    accessKeyId: "ACCESS",
    region: "us-east-1",
    dynamoDbTable: "all-events",
    secretAccessKey: "SECRET" 
});
es.put({my: "event"}, function (error) {
    if (error) console.log('put failed :/'); 
});

DynamoDb table shall be set to have a Hash key only with name key and type String.

Event keys look like following example: 20130927T005240652508858176.

Events are stored as JSON strings in a String column named body. For example:

es.put({my: "event"});
// results in:
// key                          | body
// 20130927T005240652508858176  | {"my":"event"}
// (both columns are of type String)

Documentation

DynamoDbEventStore

Public API

new DynamoDbEventStore(options)

  • options:
    • AWS: Object (Default: require('aws-sdk');) An instance of aws-sdk.
    • accessKeyId: String AWS access key ID.
    • region: String The region to send service requests to.
    • dynamoDbTable: String The name of DynamoDB table to use for event store.
    • secretAccessKey: String AWS secret access key.
    • sslEnabled: Boolean (Default: true) Whether to enable SSL for requests.

Creates a new DynamoDbEventStore instance.

dynamoDbEventStore.put(event, [callback])

  • event: Object JavaScript object representing the event to store.
  • callback: Function (Default: undefined) An optional callback to call on success or failure.

Attempts to store the event in DynamoDb. If a callback is provided it will be called with error set to true if an error occurs or with no parameters otherwise.

dynamoDbEventStore.put({foo: 'bar'}, function (error) {
    if (error) console.log('put failed :/'); 
});

Event ~trace

  • message: String Trace message.

Emitted to trace internal execution of DynamoDbEventStore instance.

npm loves you