@bahatron/mercurios
TypeScript icon, indicating that this package has built-in type declarations

3.1.4 • Public • Published

Mercurios

Event Sourcing != Async Messaging

Notes

  • Event ordering is not guaranteed. However, it's possible to use expectedSeq when publishing to control the order of events in a stream

Getting Started

npm install --save @bahatron/mercurios
import mercurios from "@bahatron/mercurios";

let client = mercurios.connect({ url: "postgres://postgres:5432" });

// appends an event to topic
let event = await client.append("myTopic", {
    data: { foo: "bar" },
    expectedSeq: 5,
});

// fetch an event by sequence
let event = await client.read("myTopic", 2);

// filter topic events
let events = await client.filter("myTopic", {
    from: 1,
    to: 5,
    before: "2021-09-01",
    key: "a_key",
});

// lists topics
let topics = await client.topics({
    like: "user.*",
    withEvents: {
        after: "2021",
    },
});

Dev Environment

npm install && npm run dev

Migration from v2 to v3

  • Only Postgres Driver is available currently in v3
  • No need for HTTP server anymore, just npm install and code away!
  • NATS is no longer a dependency
  • Subscribing to topics is no longer possible
  • Emit event method removed
  • "publish" method renamed to "append"
  • Event data structure changes:
    • published_at -> timestamp

Readme

Keywords

none

Package Sidebar

Install

npm i @bahatron/mercurios

Weekly Downloads

73

Version

3.1.4

License

Apache-2.0

Unpacked Size

141 kB

Total Files

63

Last publish

Collaborators

  • bahatron