elasticsearch-dynamodb-stream-extension
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

elasticsearch-dynamodb-stream-extension

Library facilitate sync-ing dynamodb stream records into elasticsearch

Client Extension

All extension will be extended as ddbStream.<extension function name>

import { Client } from '@elastic/elasticsearch';
import { extendClient } from 'elasticsearch-dynamodb-stream-extension';

const client = new Client({ node: 'http://localhost:9200' });

const extendedClient = extendClient(client, {
  keyGen: record => record.dynamodb.Keys.id.S,
  index: () => 'test'
});

const fakeRecord = {...}

extendedClient.ddbStream.handleRecord(fakeRecord)
  .then(console.log)
  .catch(console.error)

Extension config

export interface ExtensionConfiguration {
  /**
   * genereate id, by default it hashes unmarshalled 'record.dynamodb.Keys'
   */
  keyGen?: (record: Record) => string,

  /**
   * specify which index to sync the record to
   */
  index: (record: Record) => string
}

Extension Functions

ddbStream.validateRecord(r: Record) => void

Validate a single record, throw error when record misses new image

ddbStream.handleRecord(r: Record) => Promise // same promise es js client returns

Handle sync-ing one single record

INSERT and MODIFY event corresponds to creating/overwriting a document

REMOVE event means deleting the document

Package Sidebar

Install

npm i elasticsearch-dynamodb-stream-extension

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

3.22 kB

Total Files

2

Last publish

Collaborators

  • floydding