Class: CorosyncCommander::Execution::Message
- Inherits:
-
Object
- Object
- CorosyncCommander::Execution::Message
- Defined in:
- lib/corosync_commander/execution/message.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#execution_id ⇒ Object
readonly
Returns the value of attribute execution_id.
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Message
constructor
A new instance of Message.
- #reply(content) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Message
Returns a new instance of Message.
30 31 32 33 34 35 36 |
# File 'lib/corosync_commander/execution/message.rb', line 30 def initialize(params = {}) @sender = params[:sender] @recipients = Corosync::CPG::MemberList.new(params[:recipients]) @execution_id = params[:execution_id] @type = params[:type] @content = params[:content] end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
10 11 12 |
# File 'lib/corosync_commander/execution/message.rb', line 10 def content @content end |
#execution_id ⇒ Object (readonly)
Returns the value of attribute execution_id.
8 9 10 |
# File 'lib/corosync_commander/execution/message.rb', line 8 def execution_id @execution_id end |
#recipients ⇒ Object (readonly)
Returns the value of attribute recipients.
7 8 9 |
# File 'lib/corosync_commander/execution/message.rb', line 7 def recipients @recipients end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
6 7 8 |
# File 'lib/corosync_commander/execution/message.rb', line 6 def sender @sender end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/corosync_commander/execution/message.rb', line 9 def type @type end |
Class Method Details
.from_cpg_message(sender, data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/corosync_commander/execution/message.rb', line 12 def self.(sender, data) data = JSON.parse(data) recipients = Corosync::CPG::MemberList.new data[0].each do |m| nodeid,pid = m.split(':').map{|i| i.to_i} recipients << Corosync::CPG::Member.new(nodeid,pid) end execution_id = data[1] type = data[2] content = data[3] self.new(:sender => sender, :recipients => recipients, :execution_id => execution_id, :type => type, :content => content) end |
Instance Method Details
#reply(content) ⇒ Object
38 39 40 |
# File 'lib/corosync_commander/execution/message.rb', line 38 def reply(content) self.class.new(:recipients => [@sender], :execution_id => @execution_id, :type => 'response', :content => content) end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/corosync_commander/execution/message.rb', line 42 def to_s [@recipients.to_a, @execution_id, @type, @content].to_json end |