Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.7"
".": "0.1.0"
}
8 changes: 5 additions & 3 deletions Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ minimal DSL for defining endpoints and middleware.

== Features

* Declarative endpoint definitions with `endpoint`.
* Middleware support using `use`.
* Simple concurrency via `run` with a configurable number of instances.
* Declarative endpoint definitions with `#endpoint`.
* Grouping of endpoints with `#group`
* Simple concurrency via `#run` with a configurable number of instances.
* JSON aware message wrapper that gracefully handles parse errors.
* Middleware support using `#use`.
* Railway Oriented Design, using {dry-monads} for success and failure handling.
* {dry-configurable} settings container.
* `#logger` defaults to SemanticLogger (adjustable as the `#logger=` setting)

== Requirements

Expand Down
1 change: 1 addition & 0 deletions lib/leopard/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module Rubyists
module Leopard
class Error < StandardError; end
class ConfigurationError < Error; end
class ResultError < Error; end
end
end
5 changes: 5 additions & 0 deletions lib/leopard/nats_api_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,22 @@ def handle_message(raw_msg, handler)

# Processes the result of the handler execution.
#
#
# @param wrapper [MessageWrapper] The message wrapper containing the raw message.
# @param result [Dry::Monads::Result] The result of the handler execution.
#
# @return [void]
# @raise [ResultError] If the result is not a Success or Failure monad.
def process_result(wrapper, result)
case result
in Dry::Monads::Success
wrapper.respond(result.value!)
in Dry::Monads::Failure
logger.error 'Error processing message: ', result.failure
wrapper.respond_with_error(result.failure)
else
logger.error('Unexpected result: ', result:)
raise ResultError, "Unexpected Response from Handler, must respond with a Success or Failure monad: #{result}"
end
end
end
Expand Down