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

@millstream/kafka

v0.5.0

Published

Apache Kafka Publisher/Subscriber for @millstream (on @platformatic/kafka): commit on ack, in-place redelivery on nack, per-partition ordering

Readme

@millstream/kafka

Apache Kafka Publisher / Subscriber for millstream, built on @platformatic/kafka (pure TypeScript, no native addon). Peer dependency: @platformatic/kafka@^1.30.

import { KafkaPublisher, KafkaSubscriber } from '@millstream/kafka';

const publisher = new KafkaPublisher({
  bootstrapBrokers: ['localhost:9092'],
  partitionKey: (topic, msg) => msg.metadata.order_id, // same key → same partition → ordered
});

router.addConsumerHandler({
  name: 'billing',
  subscribeTopic: 'orders.created',
  subscriber: new KafkaSubscriber({
    bootstrapBrokers: ['localhost:9092'],
    consumerGroup: 'billing',
    partitionConcurrency: 4,
  }),
  concurrency: 4,
  handler: async (msg) => {
    /* … */
  },
});

Semantics

  • Ack → commit offset + 1 of that partition. Unanswered messages are never committed; after a restart or rebalance they come back (at-least-once — dedupe by msg.uuid, e.g. with inbox() from @millstream/pg).
  • Nack → in-place redelivery of a fresh copy after nackResendMs (Kafka has no per-message nack). A poison message therefore blocks its partition only: add poisonQueue / retry middlewares on the Router.
  • Ordering: strict per partition. partitionConcurrency: n processes up to n partitions in parallel, each still sequential; give the Router handler the same concurrency.
  • New consumer groups start at the earliest offset (fallbackMode: 'latest' to change).
  • uuid & metadata travel as headers (_millstream_message_uuid + one header per metadata key). To exchange messages with Go Watermill services, set uuidHeader: WATERMILL_UUID_HEADER on both the publisher and the subscriber. Records produced by other clients get a deterministic uuid kafka:<topic>:<partition>:<offset>.
  • kafkaInfo(msg) returns topic / partition / offset / key / timestamp of a consumed message.

Producer notes

  • The publisher's producer is idempotent by default. When part of a multi-partition Produce request fails (for example NOT_LEADER_OR_FOLLOWER right after topic creation or during a leader change), @platformatic/kafka resends the whole request, including partitions the broker already acknowledged. Without idempotence those records are appended again, while send() still succeeds. With idempotence the broker discards the resends.
  • Sends are serialised per producer: with several idempotent sends in flight, one that overtakes another's retry can land out of order (platformatic/kafka#472). For throughput, pass many messages to one publish() call.
  • Requires @platformatic/kafka ≥ 2.3: older versions silently dropped concurrent idempotent sends (#326).