Module: Rubyists::Leopard::NatsApiServer::MessageHandling
- Defined in:
- lib/leopard/nats_api_server.rb
Overview
Message execution helpers shared by request/reply and JetStream transports.
Instance Method Summary collapse
-
#build_endpoint(parent, ept) ⇒ void
private
Builds an endpoint in the NATS service.
-
#execute_handler(wrapper, handler) ⇒ Dry::Monads::Result
private
Executes an endpoint handler within the worker instance context.
-
#logger ⇒ Object
Returns the logger configured for the NATS API server.
-
#message_processor ⇒ MessageProcessor
private
Returns the memoized message processor for this worker instance.
-
#process_transport_message(raw_msg, handler, callbacks) ⇒ Object
private
Processes a raw transport message through Leopard’s middleware and callback pipeline.
-
#request_reply_callbacks ⇒ NatsRequestReplyCallbacks
private
Returns the callback helper for request/reply endpoints.
Instance Method Details
#build_endpoint(parent, ept) ⇒ void (private)
This method returns an undefined value.
Builds an endpoint in the NATS service.
454 455 456 457 458 |
# File 'lib/leopard/nats_api_server.rb', line 454 def build_endpoint(parent, ept) parent.endpoints.add(ept.name, subject: ept.subject, queue: ept.queue) do |raw_msg| (raw_msg, ept.handler, request_reply_callbacks.callbacks) end end |
#execute_handler(wrapper, handler) ⇒ Dry::Monads::Result (private)
Executes an endpoint handler within the worker instance context.
496 497 498 |
# File 'lib/leopard/nats_api_server.rb', line 496 def execute_handler(wrapper, handler) instance_exec(wrapper, &handler) end |
#logger ⇒ Object
Returns the logger configured for the NATS API server.
443 |
# File 'lib/leopard/nats_api_server.rb', line 443 def logger = self.class.logger |
#message_processor ⇒ MessageProcessor (private)
Returns the memoized message processor for this worker instance.
481 482 483 484 485 486 487 488 |
# File 'lib/leopard/nats_api_server.rb', line 481 def @message_processor ||= MessageProcessor.new( wrapper_factory: MessageWrapper.method(:new), middleware: -> { self.class.middleware }, execute_handler: method(:execute_handler), logger:, ) end |
#process_transport_message(raw_msg, handler, callbacks) ⇒ Object (private)
Processes a raw transport message through Leopard’s middleware and callback pipeline.
467 468 469 |
# File 'lib/leopard/nats_api_server.rb', line 467 def (raw_msg, handler, callbacks) .process(raw_msg, handler, callbacks) end |
#request_reply_callbacks ⇒ NatsRequestReplyCallbacks (private)
Returns the callback helper for request/reply endpoints.
474 475 476 |
# File 'lib/leopard/nats_api_server.rb', line 474 def request_reply_callbacks @request_reply_callbacks ||= NatsRequestReplyCallbacks.new(logger:) end |