Socket
Socket
Sign inDemoInstall

@equinox-js/message-db-source

Package Overview
Dependencies
38
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @equinox-js/message-db-source

The `@equinox-js/message-db-source` library provides a convenient API for consuming events from a MessageDB instance. It's designed to be used with equinox-js projects but can be used in any node application.


Version published
Weekly downloads
82
increased by36.67%
Maintainers
1
Install size
2.16 MB
Created
Weekly downloads
 

Readme

Source

@equinox-js/message-db-source

The @equinox-js/message-db-source library provides a convenient API for consuming events from a MessageDB instance. It's designed to be used with equinox-js projects but can be used in any node application.

Features

  • High throughput message consumption
  • Integrated checkpointer for resuming from last processed event
  • Configurable batch sizes for event fetching
  • Support for handling multiple concurrent streams
  • Automatic reconnection and backoff
import { MessageDbSource, PgCheckpoints } from "@equinox-js/message-db-source"
import pg from "pg"

const checkpointer = new PgCheckpoints(new pg.Pool({ connectionString: "..." }), "public")
await checkpointer.ensureTable() // creates the checkpoints table if it doesn't exist

const pool = new pg.Pool({ connectionString: "..." })

const source = MessageDbSource.create({
  pool, // the database pool to use
  batchSize: 500, // under the hood the source polls for baches of events, this controls the batch size
  categories: ["Invoice"], // list of categories to subscribe to.
  groupName: "InvoiceAutoEmailer", // Consumer group name (used for checkpointing and tracing)
  checkpointer, // the checkpointer maintains checkpoints on per category per group basis
  // Your handler will receive a list of events for a given stream
  handler: async (streamName, events) =>
    console.log("received", events.length, "events for", streamName),
  tailSleepIntervalMs: 100, // If we reach the end of the event store, how long should we wait before requesting a new batch?
  maxConcurrentStreams: 10, // How many streams are we OK to process concurrently?
})

const ctrl = new AbortController()
source.start(ctrl.signal)

FAQs

Last updated on 09 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc