Class: RightAMQP::HABrokerClient::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/right_amqp/ha_client/ha_broker_client.rb

Overview

Message publishing context

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options, 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 = options
  @brokers = brokers
  @failed  = []
end

Instance Attribute Details

#brokersObject (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

#failedObject (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

#fromObject (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

#nameObject (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_wayObject (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

#optionsObject (readonly)

(Hash) Options used to publish message



54
55
56
# File 'lib/right_amqp/ha_client/ha_broker_client.rb', line 54

def options
  @options
end

#tokenObject (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

#typeObject (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