@1mill/journal

0.6.1 • Public • Published

@1mill/journal

Idempotently invoke AWS Lambda functions with Cloudevents.

Getting started

npm install @1mill/journal
// * index.js
import { Locker, withIdempotency } from '@1mill/journal'

const locker = new Locker({
  name:  'my-locker-db-name',
  table: 'my-collection-name',
  uri:   'mongodb://...:27017/',
})

const func = (cloudevent, ctx) => {
  console.log('Running once: ', cloudevent)
  return { cloudevent }
}

export const handler = async (cloudevent, ctx) => withIdempotency(cloudevent, ctx, { func, locker })

Locker

Name Required Types Default Environment Description
expireAfterSeconds number 86400 (1 day) MILL_JOURNAL_EXPIRE_AFTER_SECONDS How long a Cloudevent idempotency key will keep-alive
name yes string MILL_JOURNAL_NAME The name of the database itself
options object {} Options pass to the database client
table yes string MILL_JOURNAL_TABLE The name of the table inside the database
uri yes string MILL_JOURNAL_URI URI to connect to database

withIdempotency

Name Required Types Default Environment Description
func yes function The function containing business logic that will run
locker yes Locker The Locker in which idempotency keys will be checked against

References

Readme

Keywords

Package Sidebar

Install

npm i @1mill/journal

Weekly Downloads

13

Version

0.6.1

License

MIT

Unpacked Size

5.43 MB

Total Files

19

Last publish

Collaborators

  • 1mill