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

@quanticjs/events-kafka

v8.2.0

Published

Kafka transport for @quanticjs/events-core — KafkaEventPublisher, KafkaEventConsumer with ADR-008 compliance

Downloads

2,442

Readme

@quanticjs/events-kafka

Kafka transport for @quanticjs/events-coreKafkaEventPublisher, KafkaEventConsumer with retry/DLQ machinery, inbox dedup, consumer health, and Prometheus metrics.

Metrics

All metrics are registered against the prom-client default global registry (promClient.register), the same registry @quanticjs/metrics' MetricsController serves at GET /metrics. There is no DI coupling between the packages:

  • @quanticjs/metrics absent: events-kafka still records into the default registry (if the consumer app has prom-client installed), but no endpoint serves it — the app simply has no /metrics.
  • prom-client absent: all metrics are silent no-ops.

| Name | Type | Labels | |---|---|---| | quanticjs_events_published_total | Counter | topic | | quanticjs_events_consumed_total | Counter | topic, group, status | | quanticjs_events_processing_duration_seconds | Histogram | topic, group | | quanticjs_events_dlq_total | Counter | topic, error_category | | quanticjs_events_consumer_lag | Gauge | topic, group, partition | | quanticjs_events_last_processed_timestamp_seconds | Gauge | topic, group |

Consumer lag

quanticjs_events_consumer_lag is updated by a periodic admin/watermark probe (lagProbeIntervalMs, default 30000; 0 disables it) and reports max(0, high watermark − position) per assigned partition. Probe failures are logged at debug and never affect consumption; the gauge keeps its last value.

Detecting a stuck consumer

A true oldest-unprocessed-age gauge is not feasible cheaply (it would require fetching the next unconsumed message per partition per probe). Use the last-processed-timestamp proxy — alert when both hold:

time() - quanticjs_events_last_processed_timestamp_seconds > 300
and
quanticjs_events_consumer_lag > 0

Lag with no recent processing means the consumer is stuck, not idle.

Two prom-client copies (version skew)

prom-client is a peerDependency of both @quanticjs/metrics and @quanticjs/events-kafka so npm hoists a single copy. If version skew ever produces two copies in node_modules, each has its own default registry and kafka metrics silently disappear from /metrics again. Check with:

npm ls prom-client   # must show exactly one resolved version

Consumer health & boot behavior

Each consumer tracks a status (connectingrunning; crashed on run-loop failure; disconnected on shutdown) and registers itself with KafkaConsumerStatusRegistry, which @quanticjs/health's HealthRegistry auto-detects (via the KAFKA_CONSUMER_STATUS token from @quanticjs/core) as a kafka_consumers readiness check. A crashed run-loop turns readiness red within one health-cache TTL (default 5000ms) and Kubernetes restarts the pod — there is no in-process auto-restart in v7.

Boot connect options on KafkaEventsModuleOptions:

connectRetries?: number;            // default 5
connectRetryBaseMs?: number;        // default 1000; exponential ×2, cap 30000, full jitter
connectFailurePolicy?: 'fail' | 'degrade';  // default 'fail'
lagProbeIntervalMs?: number;        // default 30000; 0 disables the lag probe

With 'fail' (default) boot throws after retry exhaustion. With 'degrade' the app boots, the kafka_consumers readiness check reports the consumer crashed (connect_failed), and connect retries continue in the background; on success the consumer starts and readiness recovers.