Class: RightAMQP::HABrokerClient::Context
- Inherits:
-
Object
- Object
- RightAMQP::HABrokerClient::Context
- Defined in:
- lib/right_amqp/ha_client/ha_broker_client.rb
Overview
Message publishing context
Instance Attribute Summary collapse
-
#brokers ⇒ Object
readonly
(Array) Identity of candidate brokers when message was published.
-
#failed ⇒ Object
readonly
(Array) Identity of brokers that have failed to deliver message with last one at end.
-
#from ⇒ Object
readonly
(String) Original sender of message if applicable.
-
#name ⇒ Object
readonly
(String) Message class name in lower snake case.
-
#one_way ⇒ Object
readonly
(Boolean) Whether the packet is one that does not have an associated response.
-
#options ⇒ Object
readonly
(Hash) Options used to publish message.
-
#token ⇒ Object
readonly
(String) Generated message identifier if applicable.
-
#type ⇒ Object
readonly
(String) Request type if applicable.
Instance Method Summary collapse
-
#initialize(packet, options, brokers) ⇒ Context
constructor
Create context.
-
#record_failure(identity) ⇒ Object
Record delivery failure.
Constructor Details
#initialize(packet, options, brokers) ⇒ Context
Create context
Parameters
- packet(Packet)
-
Packet being published
- options(Hash)
-
Publish options
- brokers(Array)
-
Identity of candidate brokers
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 68 def initialize(packet, , brokers) @name = (packet.respond_to?(:name) ? packet.name : packet.class.name.snake_case) @type = (packet.type if packet.respond_to?(:type) && packet.type != packet.class) @from = (packet.from if packet.respond_to?(:from)) @token = (packet.token if packet.respond_to?(:token)) @one_way = (packet.respond_to?(:one_way) ? packet.one_way : true) @options = @brokers = brokers @failed = [] end |
Instance Attribute Details
#brokers ⇒ Object (readonly)
(Array) Identity of candidate brokers when message was published
57 58 59 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 57 def brokers @brokers end |
#failed ⇒ Object (readonly)
(Array) Identity of brokers that have failed to deliver message with last one at end
60 61 62 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 60 def failed @failed end |
#from ⇒ Object (readonly)
(String) Original sender of message if applicable
45 46 47 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 45 def from @from end |
#name ⇒ Object (readonly)
(String) Message class name in lower snake case
39 40 41 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 39 def name @name end |
#one_way ⇒ Object (readonly)
(Boolean) Whether the packet is one that does not have an associated response
51 52 53 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 51 def one_way @one_way end |
#options ⇒ Object (readonly)
(Hash) Options used to publish message
54 55 56 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 54 def @options end |
#token ⇒ Object (readonly)
(String) Generated message identifier if applicable
48 49 50 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 48 def token @token end |
#type ⇒ Object (readonly)
(String) Request type if applicable
42 43 44 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 42 def type @type end |
Instance Method Details
#record_failure(identity) ⇒ Object
Record delivery failure
Parameters
- identity(String)
-
Identity of broker that failed delivery
Return
- true
-
Always return true
86 87 88 |
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 86 def record_failure(identity) @failed << identity end |