Skip to content

feat: add NATS service discovery tools - #59

Merged
bougyman merged 1 commit into
mainfrom
feat/nats-service-discovery-58
Sep 16, 2026
Merged

bougyman merged 1 commit into
mainfrom
feat/nats-service-discovery-58

Conversation

@bougyman

Copy link
Copy Markdown
Member

Summary

  • add NATS Service API discovery helpers and command-line tools
  • expose service information, statistics, and endpoint subject maps
  • declare the minimal trailblazer-operation runtime dependency

Closes #58

Validation

  • bundle exec rake ci (49 runs, 104 assertions; 0 failures, 0 errors, 0 skips)

Copilot AI lite review requested due to automatic review settings September 15, 2026 19:41
@bougyman
bougyman enabled auto-merge (squash) September 15, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 server and creds, so NATS.connect keeps 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 to abort_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
bougyman force-pushed the feat/nats-service-discovery-58 branch from 813ceea to 5bc05cb Compare September 15, 2026 19:53
@bougyman bougyman self-assigned this Sep 16, 2026
@bougyman
bougyman merged commit 382d5e7 into main Sep 16, 2026
5 checks passed
@bougyman
bougyman deleted the feat/nats-service-discovery-58 branch September 16, 2026 15:58
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.

feat: add NATS service discovery tools

3 participants