Skip to content

feat: add nats_jetstream_consumer to provide the feature requested in issue #44#45

Open
bougyman wants to merge 9 commits intomainfrom
44-feature-request-jetstream-consumer-support-via-dsl
Open

feat: add nats_jetstream_consumer to provide the feature requested in issue #44#45
bougyman wants to merge 9 commits intomainfrom
44-feature-request-jetstream-consumer-support-via-dsl

Conversation

@bougyman
Copy link
Copy Markdown
Member

This add a NatsJetstreamConsumer class which provides the same
concurrency primitives and connection handling that the
NatsApiServer does for NATS service api processes. Example
included for usage.

closes #44

@bougyman bougyman requested review from a team and Copilot April 16, 2026 18:36
@bougyman bougyman linked an issue Apr 16, 2026 that may be closed by this pull request
5 tasks
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class NATS JetStream pull-consumer support to Leopard’s DSL/runtime, reusing the existing middleware + Dry::Monads::Result handler contract and worker lifecycle model (issue #44).

Changes:

  • Introduces jetstream_endpoint DSL plus NatsJetstreamConsumer to run pull subscriptions per worker instance.
  • Extracts common message execution/middleware/result-routing into MessageProcessor, with separate callback sets for request/reply vs JetStream.
  • Adds JetStream integration tests + example, and updates CI tooling to run tests against a managed local JetStream broker.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/leopard/nats_api_server.rb Adds jetstream_endpoint DSL, wires JetStream consumer startup, and routes all message handling through MessageProcessor.
lib/leopard/message_processor.rb New shared middleware/handler/result routing component used by both request/reply and JetStream flows.
lib/leopard/nats_jetstream_consumer.rb New pull-consumer loop (threads, fetch, dispatch) for JetStream endpoints.
lib/leopard/nats_jetstream_callbacks.rb New JetStream ack/nak/term callbacks based on handler outcomes.
lib/leopard/nats_jetstream_endpoint.rb New struct describing JetStream endpoint configuration/options.
lib/leopard/nats_request_reply_callbacks.rb New request/reply callbacks (respond, respond_with_error) extracted from prior inline logic.
lib/leopard.rb Exposes new components from the top-level require.
test/lib/nats_api_server.rb Updates tests to exercise jetstream_endpoint registration and MessageProcessor routing behavior.
test/lib/nats_request_reply_callbacks_test.rb New unit tests for request/reply callback behavior.
test/integration/nats_jetstream_integration_test.rb New integration coverage for ack-on-success, nak/redelivery-on-failure, term-on-exception, and middleware execution.
examples/jetstream_endpoint.rb Usage example for defining and running a JetStream consumer endpoint.
Rakefile Adds rake ci orchestration to start/stop a local NATS JetStream container and run tests.
ci/nats/start.sh Adds configurable container name/detach mode and builds docker/podman args more flexibly.
.github/workflows/main.yaml Switches CI to rake ci and uses local container startup instead of GH Actions “services”.
Readme.adoc Documents JetStream pull consumer DSL and updates dev instructions to use rake ci.
Gemfile.lock Bumps gem version to 0.2.5 in the lockfile.
.gitignore Ignores .rubocop_cache.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Rakefile Outdated
@rubyists rubyists deleted a comment from Copilot AI Apr 16, 2026
@rubyists rubyists deleted a comment from Copilot AI Apr 16, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bougyman bougyman force-pushed the 44-feature-request-jetstream-consumer-support-via-dsl branch from 1681de1 to 671eae9 Compare April 16, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: JetStream Consumer Support via DSL

2 participants