npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@argos-js/events

v0.1.2

Published

Event-driven architecture suite with pluggable brokers (Kafka, RabbitMQ, Redis, Memory) and Transactional Outbox pattern for Argos-JS

Readme

@argos-js/events

High-performance, runtime-agnostic event-driven messaging suite for Argos-JS, featuring first-class support for native CDC engine ArgosDB Pulse (port 8788, binary Bincode 1.x Little-Endian framing) and interchangeable broker drivers.


Features

  • Runtime-Agnostic Binary Serialization: 100% pure TypeScript Bincode 1.x Little-Endian encoder/decoder built on standard Web APIs (Uint8Array, DataView, TextEncoder, TextDecoder), with zero native C/C++ dependencies. Fully portable across Node.js 18+, Bun, and Deno.
  • Pluggable Event Drivers:
    • pulse: Native CDC/WAL stream consumer for ArgosDB Pulse (argosdb-pulse, port 8788).
    • memory: High-performance, zero-dependency in-memory pub/sub broker for unit testing and CI.
    • rabbitmq: Enterprise AMQP topic exchanges with competing consumer queues.
    • redis: Redis Streams consumer groups and Pub/Sub.
    • kafka: Apache Kafka cluster consumer groups and partitioned topics.
  • ArgosDB Pulse Protocol:
    • Sub-millisecond binary TCP framing ([4-byte LE payload length][bincode payload]).
    • Native client OpCodes: Subscribe (0x00), JoinGroup (0x01), Ack (0x02), Nack (0x03), SeekHlc (0x04).
    • High-resilience PulseStreamParser with cumulative buffer for seamless TCP packet chunking and backpressure handling.
    • Automatic reconnection with exponential backoff and transparent consumer group re-registration.
  • Consumer Groups & CDC Records: Competing consumers with automatic or manual ctx.ack() and ctx.nack(), plus event.jsonPayload<T>() helper.
  • Transactional Outbox Pattern: Atomic domain event emission within database transactions, guaranteed at-least-once delivery with background polling relay.

Installation

pnpm add @argos-js/events

Configuration & Drivers

Configure the active driver via code or environment variables:

# Select active driver: pulse | memory | rabbitmq | redis | kafka
EVENTS_DRIVER=pulse

# ArgosDB Pulse CDC connection
ARGOS_PULSE_HOST=127.0.0.1
ARGOS_PULSE_PORT=8788

Initializing the Events Manager

import { createEventsManager } from '@argos-js/events';

export const events = createEventsManager({
  driver: (process.env.EVENTS_DRIVER as any) || 'pulse',
  pulse: {
    host: process.env.ARGOS_PULSE_HOST || '127.0.0.1',
    port: Number(process.env.ARGOS_PULSE_PORT) || 8788,
    autoAck: false, // Manual acknowledgement via ctx.ack() / ctx.nack()
  },
  outbox: {
    enabled: true,
    tableName: 'events_outbox',
    pollIntervalMs: 1000,
  },
});

Usage: Consumer Groups (CDC Mutations)

ArgosDB Pulse automatically publishes mutation events from write-ahead logs (INSERT, UPDATE, DELETE) on channels such as cdc.auth_users.*.

import { events, MutationOp } from '@argos-js/events';

await events.connect();

// Join consumer group 'email_workers'
await events.subscribeGroup({
  group: 'email_workers',
  workerId: `worker-${process.pid}`,
  pattern: 'cdc.auth_users.*',
  handler: async (record, ctx) => {
    // Check mutation operation
    if (record.event.op === MutationOp.Insert) {
      // Decode JSON from afterPayload
      const user = record.event.jsonPayload<{ id: string; name: string; email: string }>();
      if (user?.email) {
        console.log(`[EmailWorker] ✉️ Sending welcome email to: ${user.name} <${user.email}>`);
        await sendWelcomeEmail(user);
      }
    }

    // Acknowledge processing
    await ctx.ack();
  },
});

Binary Protocol Specification (ArgosDB Pulse)

Frame Layout

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               Payload Length (4 bytes, Little-Endian)         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        Bincode 1.x Serialized Payload (Little-Endian)         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Supported OpCodes (Client -> Server)

| Tag (u32 LE) | Variant | Fields | | :--- | :--- | :--- | | 0x00 | Subscribe | pattern: String | | 0x01 | JoinGroup | group_name: String, consumer_id: String, pattern: String | | 0x02 | Ack | group_name: String, message_id: u128 | | 0x03 | Nack | group_name: String, message_id: u128 | | 0x04 | SeekHlc | hlc: u128 |

Server Frames (Server -> Client)

| Tag (u32 LE) | Variant | Structure | | :--- | :--- | :--- | | 0 | Subscribed | pattern: String | | 1 | JoinedGroup | group_name: String, consumer_id: String | | 2 | Record | topic: String, event: MutationEvent | | 3 | GroupRecord | group_name: String, consumer_id: String, message_id: u128, topic: String, event: MutationEvent | | 4 | AckResult | ok: bool, message_id: u128 | | 5 | NackResult | ok: bool, message_id: u128 | | 6 | Error | message: String |


Transactional Outbox Pattern

Emit events safely within ACID database transactions:

await db.transaction(async (trx) => {
  const user = await trx.from('users').insert({ name: 'Alice' }).returning('*');

  // Automatically writes to events_outbox in the same transaction
  await trx.events.emit('user.created', { id: user.id, name: user.name });
});

License

MIT © Argos-JS Team