leopard 0.2.2 → 0.2.4
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 +4 -4
- data/.release-please-manifest.json +1 -1
- data/.version.txt +1 -1
- data/CHANGELOG.md +14 -0
- data/examples/echo_endpoint.rb +13 -3
- data/lib/leopard/errors.rb +18 -1
- data/lib/leopard/message_wrapper.rb +3 -3
- data/lib/leopard/nats_api_server.rb +1 -1
- data/lib/leopard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91aa4b92bca51e6d8b73238440961b9f3f43a0cbad93e7faa8a905ed25cf0ae0
|
|
4
|
+
data.tar.gz: '060265234152419f9ccffae0177c83cf3a6e9d175d453fb4657163a419ce7ed9'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7f3a1b44ac12f62f1bd0fd06aa9a5e48d0007f022f6664929b569e0016587d24adce6c2e3e5fb7ed769a38509d3e83e79c80e891c7470c61c6848fede6380a2
|
|
7
|
+
data.tar.gz: 33416a919d4e8f073ea9b89a46ede9aae3979284f2614b868a997fd3e6f21dae98802755203139a55facb58c4aad16a0a5fdc42499cf7cfc04521d5eff8c3126
|
data/.version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.4](https://github.com/rubyists/leopard/compare/v0.2.3...v0.2.4) (2026-03-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* preserve respond_with_error payloads ([#40](https://github.com/rubyists/leopard/issues/40)) ([f5c0d46](https://github.com/rubyists/leopard/commit/f5c0d463ec85556c731da1251897f27f2816310b))
|
|
9
|
+
|
|
10
|
+
## [0.2.3](https://github.com/rubyists/leopard/compare/v0.2.2...v0.2.3) (2025-08-16)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* [#35](https://github.com/rubyists/leopard/issues/35) - Limits the backtrace to 4 lines in our exceptions ([#36](https://github.com/rubyists/leopard/issues/36)) ([df0fee8](https://github.com/rubyists/leopard/commit/df0fee8373fc0088cd61abcc3e6d963e957730b6))
|
|
16
|
+
|
|
3
17
|
## [0.2.2](https://github.com/rubyists/leopard/compare/v0.2.1...v0.2.2) (2025-08-15)
|
|
4
18
|
|
|
5
19
|
|
data/examples/echo_endpoint.rb
CHANGED
|
@@ -7,16 +7,26 @@ require_relative '../lib/leopard/nats_api_server'
|
|
|
7
7
|
class EchoService
|
|
8
8
|
include Rubyists::Leopard::NatsApiServer
|
|
9
9
|
|
|
10
|
+
config.logger = SemanticLogger[:EchoService]
|
|
10
11
|
def initialize(a_var: 1)
|
|
11
12
|
logger.info "EchoService initialized with a_var: #{a_var}"
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
endpoint(:echo)
|
|
15
|
-
|
|
15
|
+
endpoint(:echo) do |msg|
|
|
16
|
+
data = msg.data
|
|
17
|
+
logger.trace('Received message', data:)
|
|
18
|
+
Success(data)
|
|
19
|
+
end
|
|
20
|
+
endpoint(:echo_fail) do |msg|
|
|
21
|
+
data = msg.data
|
|
22
|
+
logger.trace('Received message', data:)
|
|
23
|
+
Failure({ failure: '*boom*', data: msg.data })
|
|
24
|
+
end
|
|
16
25
|
end
|
|
17
26
|
|
|
18
27
|
if __FILE__ == $PROGRAM_NAME
|
|
19
28
|
SemanticLogger.default_level = :info
|
|
29
|
+
SemanticLogger.add_signal_handler
|
|
20
30
|
SemanticLogger.add_appender(io: $stdout, formatter: :color)
|
|
21
31
|
EchoService.run(
|
|
22
32
|
nats_url: 'nats://localhost:4222',
|
|
@@ -25,6 +35,6 @@ if __FILE__ == $PROGRAM_NAME
|
|
|
25
35
|
version: '1.0.0',
|
|
26
36
|
instance_args: { a_var: 2 },
|
|
27
37
|
},
|
|
28
|
-
instances: 1,
|
|
38
|
+
instances: ENV.fetch('ECHO_INSTANCES', '1').to_i,
|
|
29
39
|
)
|
|
30
40
|
end
|
data/lib/leopard/errors.rb
CHANGED
|
@@ -2,7 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
module Rubyists
|
|
4
4
|
module Leopard
|
|
5
|
-
class
|
|
5
|
+
class LeopardError < StandardError
|
|
6
|
+
def initialize(...)
|
|
7
|
+
super
|
|
8
|
+
set_backtrace(caller)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def backtrace
|
|
12
|
+
# If the backtrace is nil, return an empty array
|
|
13
|
+
orig = (super || [])[0..3]
|
|
14
|
+
# If the backtrace is less than 4 lines, return it as is
|
|
15
|
+
return orig if orig.size < 4
|
|
16
|
+
|
|
17
|
+
# Otherwise, add a note indicating truncation
|
|
18
|
+
orig + ['... (truncated by Leopard)']
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Error < LeopardError; end
|
|
6
23
|
class ConfigurationError < Error; end
|
|
7
24
|
class ResultError < Error; end
|
|
8
25
|
end
|
|
@@ -31,11 +31,11 @@ module Rubyists
|
|
|
31
31
|
raw.respond(serialize(payload))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
# @param err [
|
|
34
|
+
# @param err [Object] The error payload to respond with.
|
|
35
35
|
#
|
|
36
36
|
# @return [void]
|
|
37
|
-
def respond_with_error(err)
|
|
38
|
-
raw.respond_with_error(err
|
|
37
|
+
def respond_with_error(err, &)
|
|
38
|
+
raw.respond_with_error(err, &)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
private
|
|
@@ -313,7 +313,7 @@ module Rubyists
|
|
|
313
313
|
process_result(wrapper, result)
|
|
314
314
|
rescue StandardError => e
|
|
315
315
|
logger.error 'Error processing message: ', e
|
|
316
|
-
wrapper.respond_with_error(e
|
|
316
|
+
wrapper.respond_with_error(e)
|
|
317
317
|
end
|
|
318
318
|
|
|
319
319
|
# Processes the result of the handler execution.
|
data/lib/leopard/version.rb
CHANGED
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.2.
|
|
4
|
+
version: 0.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- bougyman
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-03-31 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: concurrent-ruby
|