feat: add nats_jetstream_consumer to provide the feature requested in issue #44#45
Open
feat: add nats_jetstream_consumer to provide the feature requested in issue #44#45
Conversation
5 tasks
Contributor
There was a problem hiding this comment.
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_endpointDSL plusNatsJetstreamConsumerto 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1681de1 to
671eae9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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