feat: add NATS service discovery tools - #59
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings remain in response handling and CLI behavior and coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds NATS Service API discovery helpers, Trailblazer operations, and four CLI tools for service information, statistics, and endpoint subject maps.
Changes:
- Implements INFO, PING, STATS, and subject-map discovery.
- Adds CLI filtering, formatting, connection handling, and executables.
- Adds integration coverage and dependency updates.
File summaries
| File | Reviewed change / note |
|---|---|
test/integration/nats_service_discovery_test.rb |
Integration coverage for discovery workflows. |
lib/leopard/nats_service_discovery/operation/verb.rb |
Shared verb operation behavior. |
lib/leopard/nats_service_discovery/operation/subject_map.rb |
Builds endpoint subject maps. |
lib/leopard/nats_service_discovery/operation/stats.rb |
Implements service statistics discovery. |
lib/leopard/nats_service_discovery/operation/services.rb |
Summarizes discovered services. |
lib/leopard/nats_service_discovery/operation/ping.rb |
Implements PING discovery. |
lib/leopard/nats_service_discovery/operation/info.rb |
Implements INFO discovery. |
lib/leopard/nats_service_discovery/operation/discovery_options.rb |
Shared discovery operation options. |
lib/leopard/nats_service_discovery/operation/connect.rb |
Implements connection handling. |
lib/leopard/nats_service_discovery/operation/collect.rb |
Collects responses from arbitrary subjects. |
lib/leopard/nats_service_discovery/operation.rb |
Loads discovery operations. |
lib/leopard/nats_service_discovery/cli.rb |
Shared CLI parsing and output helpers. Line 44: moderate finding (1 vote) regarding reconnect behavior. Line 24: moderate finding (2 votes) requesting CLI-level or subprocess coverage. |
lib/leopard/nats_service_discovery.rb |
Core response collection and subject mapping. Line 106: critical finding (2 votes) regarding rescuing connection failures from subscription setup. |
leopard.gemspec |
Declares the Trailblazer runtime dependency. |
Gemfile.lock |
Locks dependency updates. |
exe/leopard-services |
Adds the service summary command. |
exe/leopard-service-stats |
Adds the service statistics command. |
exe/leopard-service-map |
Adds the endpoint subject-map command. |
exe/leopard-service-info |
Adds the service INFO command. |
Review details
Suppressed comments (1)
lib/leopard/nats_service_discovery/cli.rb:44
- The CLI only passes
serverandcreds, soNATS.connectkeeps its default reconnect behavior. When the configured broker is unavailable, a one-shot command can retry for the client's reconnect window instead of returning toabort_with, making these discovery tools appear hung; disable reconnect (and optionally set a short connect timeout) for this CLI connection.
result = Operation::Connect.call(server: opts[:server], creds: opts[:creds])
- Files reviewed: 18/19 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+105
to
+114
| def collect_json(subject, timeout:) | ||
| replies = [] | ||
| sub = subscribe_to_inbox | ||
| client.publish(subject, '', sub.subject) | ||
| collect_replies(sub, replies, timeout) | ||
| rescue NATS::Timeout | ||
| replies | ||
| ensure | ||
| sub&.unsubscribe | ||
| end |
| # @param json [Boolean] Whether the command supports `--json`. | ||
| # | ||
| # @return [Hash] Parsed options. | ||
| def parse(argv, banner:, description:, json: false) |
bougyman
force-pushed
the
feat/nats-service-discovery-58
branch
from
September 15, 2026 19:53
813ceea to
5bc05cb
Compare
OpenSourceAlchemist
approved these changes
Sep 16, 2026
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.
Summary
trailblazer-operationruntime dependencyCloses #58
Validation
bundle exec rake ci(49 runs, 104 assertions; 0 failures, 0 errors, 0 skips)