leopard 0.1.7 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 343e274b8fffbe093d59b1d819a4b0be0ba9efe109c4883c535ba3692f1854a3
4
- data.tar.gz: 6b32780cf1bd40d7b0191a79a533382dbc6ed828162d9c6ebeefa2c838191c77
3
+ metadata.gz: 65ca3cd49f50ce6ae1705a531c234731593f7f86bbf4b74e18edddf1dbe4a058
4
+ data.tar.gz: 9a3894b0170021820023c12c1e5124610ee7ec4b8b334591b2cb7c8d5a994986
5
5
  SHA512:
6
- metadata.gz: 2ee58b9e7a03d9dee24f3d338e700c0d0456ff0056379e06405418365023a14dc7484bad768d7deff2727cb7e01f0daa331234bfa6b0875b5891f79577a1880e
7
- data.tar.gz: '047850ac66d9a789bdaad311ef764bed2bea365776a67d6f47f9634eb039edc303ab48d6227ad443f4f2a49b5fba1f1cd63c5d45068120b544d9a1e8a65c292d'
6
+ metadata.gz: 35d2bc6ef2ea2f8d19aeae0382a5cf8e47b1a36e3085fd39e63b892831fc142d68d38cc389918f779afd3f93b3a287a5a6c8debb96fe9043aad87a0f3361cdde
7
+ data.tar.gz: 782011f1179ffcf345df77516e566c82ed3cbfbb4864b354902093a2db16d5adec2c2da47f516e9d26db1ada3a7c9d04fc23790ec014a01d26160b10b0dbac67
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.1.7"
2
+ ".": "0.2.1"
3
3
  }
data/.version.txt CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.2.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1](https://github.com/rubyists/leopard/compare/v0.2.0...v0.2.1) (2025-08-08)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Do not leak SemanticLogger settings outside of isolation ([#30](https://github.com/rubyists/leopard/issues/30)) ([524595c](https://github.com/rubyists/leopard/commit/524595c37f114ec28f40abc841ecb3c7b6579f5a))
9
+
10
+ ## [0.2.0](https://github.com/rubyists/leopard/compare/v0.1.7...v0.2.0) (2025-08-07)
11
+
12
+
13
+ ### ⚠ BREAKING CHANGES
14
+
15
+ * Big move to use kwargs as the initializer for classes which include us ([#28](https://github.com/rubyists/leopard/issues/28))
16
+
17
+ ### Bug Fixes
18
+
19
+ * Big move to use kwargs as the initializer for classes which include us ([#28](https://github.com/rubyists/leopard/issues/28)) ([72293b4](https://github.com/rubyists/leopard/commit/72293b434998679fe3ff2d467a6a39c11a325b5a))
20
+
3
21
  ## [0.1.7](https://github.com/rubyists/leopard/compare/v0.1.6...v0.1.7) (2025-08-06)
4
22
 
5
23
 
@@ -7,7 +7,7 @@ require_relative '../lib/leopard/nats_api_server'
7
7
  class EchoService
8
8
  include Rubyists::Leopard::NatsApiServer
9
9
 
10
- def initialize(a_var = 1)
10
+ def initialize(a_var: 1)
11
11
  logger.info "EchoService initialized with a_var: #{a_var}"
12
12
  end
13
13
 
@@ -16,12 +16,14 @@ class EchoService
16
16
  end
17
17
 
18
18
  if __FILE__ == $PROGRAM_NAME
19
+ SemanticLogger.default_level = :info
20
+ SemanticLogger.add_appender(io: $stdout, formatter: :color)
19
21
  EchoService.run(
20
22
  nats_url: 'nats://localhost:4222',
21
23
  service_opts: {
22
24
  name: 'example.echo',
23
25
  version: '1.0.0',
24
- instance_args: [2],
26
+ instance_args: { a_var: 2 },
25
27
  },
26
28
  instances: 1,
27
29
  )
@@ -10,10 +10,11 @@ module Rubyists
10
10
  #
11
11
  # @!attribute [r] data
12
12
  # @return [Object] The parsed data from the NATS message.
13
+ attr_reader :raw, :data
13
14
  #
14
- # @!attribute [r] headers
15
+ # @!attribute [w] headers
15
16
  # @return [Hash] The headers from the NATS message.
16
- attr_reader :raw, :data, :headers
17
+ attr_accessor :headers
17
18
 
18
19
  # @param nats_msg [NATS::Message] The NATS message to wrap.
19
20
  def initialize(nats_msg)
@@ -26,6 +27,7 @@ module Rubyists
26
27
  #
27
28
  # @return [void]
28
29
  def respond(payload)
30
+ raw.header = headers unless headers.empty?
29
31
  raw.respond(serialize(payload))
30
32
  end
31
33
 
@@ -98,6 +98,8 @@ module Rubyists
98
98
  pool = Concurrent::FixedThreadPool.new(count)
99
99
  @instance_args = opts.delete(:instance_args) || nil
100
100
  logger.info "Building #{count} workers with options: #{opts.inspect}, instance_args: #{@instance_args}"
101
+ raise ArgumentError, 'instance_args must be a Hash' if @instance_args && !@instance_args.is_a?(Hash)
102
+
101
103
  count.times do
102
104
  pool.post { build_worker(url, opts, workers, blocking) }
103
105
  end
@@ -106,18 +108,19 @@ module Rubyists
106
108
 
107
109
  # Builds a worker instance and sets it up with the NATS server.
108
110
  #
109
- # @param url [String] The URL of the NATS server.
110
- # @param opts [Hash] Options for the NATS service.
111
+ # @param nats_url [String] The URL of the NATS server.
112
+ # @param service_opts [Hash] Options for the NATS service.
111
113
  # @param workers [Array] The array to store worker instances.
112
114
  # @param blocking [Boolean] If true, blocks the current thread until the worker is set up.
113
115
  #
114
116
  # @return [void]
115
- def build_worker(url, opts, workers, blocking)
116
- worker = @instance_args ? new(*@instance_args) : new
117
+ def build_worker(nats_url, service_opts, workers, blocking)
118
+ worker = @instance_args ? new(**@instance_args) : new
117
119
  workers << worker
118
- return worker.setup_worker!(nats_url: url, service_opts: opts) if blocking
120
+ args = { nats_url:, service_opts: }
121
+ return worker.setup_worker!(**args) if blocking
119
122
 
120
- worker.setup_worker(nats_url: url, service_opts: opts)
123
+ worker.setup_worker(**args)
121
124
  end
122
125
 
123
126
  # Shuts down the NATS API server gracefully.
@@ -3,7 +3,7 @@
3
3
  module Rubyists
4
4
  module Leopard
5
5
  # x-release-please-start-version
6
- VERSION = '0.1.7'
6
+ VERSION = '0.2.1'
7
7
  # x-release-please-end
8
8
  end
9
9
  end
data/lib/leopard.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'dry/configurable'
4
4
  require 'pathname'
5
5
  require 'semantic_logger'
6
- SemanticLogger.add_appender(io: $stdout, formatter: :color)
7
6
 
8
7
  class Pathname
9
8
  def /(other)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leopard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bougyman
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-08-06 00:00:00.000000000 Z
10
+ date: 2025-08-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: concurrent-ruby