Module: ASIR::Transport::Delegation
Overview
!SLIDE A Transport that delgated to one or more other Transports.
Classes that include this must define #_send_message(message, message_payload).
Instance Attribute Summary collapse
-
#on_failed_message ⇒ Object
Proc to call(transport, message) when #send_message fails with no recourse.
-
#on_send_message_exception ⇒ Object
Proc to call(transport, message, exc) when a delegated #send_message fails.
-
#reraise_first_exception ⇒ Object
If true, reraise the first Exception that occurred during Transport#send_message.
Instance Method Summary collapse
-
#_handle_send_message_exception!(transport, state, exc) ⇒ Object
Called from within _send_message rescue.
-
#_receive_result(state) ⇒ Object
Return the subTransports’ result unmodified from #_send_message.
- #needs_message_identifier?(message) ⇒ Boolean
- #needs_message_timestamp?(message) ⇒ Boolean
-
#transports ⇒ Object
Subclasses with multiple transports should override this method.
Instance Attribute Details
#on_failed_message ⇒ Object
Proc to call(transport, message) when #send_message fails with no recourse.
15 16 17 |
# File 'lib/asir/transport/delegation.rb', line 15 def @on_failed_message end |
#on_send_message_exception ⇒ Object
Proc to call(transport, message, exc) when a delegated #send_message fails.
12 13 14 |
# File 'lib/asir/transport/delegation.rb', line 12 def @on_send_message_exception end |
#reraise_first_exception ⇒ Object
If true, reraise the first Exception that occurred during Transport#send_message.
9 10 11 |
# File 'lib/asir/transport/delegation.rb', line 9 def reraise_first_exception @reraise_first_exception end |
Instance Method Details
#_handle_send_message_exception!(transport, state, exc) ⇒ Object
Called from within _send_message rescue.
38 39 40 41 42 43 |
# File 'lib/asir/transport/delegation.rb', line 38 def transport, state, exc _log { [ :send_message, :transport_failed, exc, exc.backtrace ] } (state.[:transport_exceptions] ||= [ ]) << "#{exc.inspect}: #{exc.backtrace.first}" @on_send_message_exception.call(self, state, exc) if @on_send_message_exception self end |
#_receive_result(state) ⇒ Object
Return the subTransports’ result unmodified from #_send_message.
18 19 20 |
# File 'lib/asir/transport/delegation.rb', line 18 def _receive_result state true end |
#needs_message_identifier?(message) ⇒ Boolean
22 23 24 25 |
# File 'lib/asir/transport/delegation.rb', line 22 def @needs_message_identifier || transports.any? { | t | t.() } end |
#needs_message_timestamp?(message) ⇒ Boolean
27 28 29 30 |
# File 'lib/asir/transport/delegation.rb', line 27 def @needs_message_timestamp || transports.any? { | t | t.() } end |
#transports ⇒ Object
Subclasses with multiple transports should override this method.
33 34 35 |
# File 'lib/asir/transport/delegation.rb', line 33 def transports @transports ||= [ transport ] end |