Class: Rafka::Message
- Inherits:
-
Object
- Object
- Rafka::Message
- Defined in:
- lib/rafka/message.rb
Overview
Message represents a message consumed from a topic.
Instance Attribute Summary collapse
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#partition ⇒ Object
readonly
Returns the value of attribute partition.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(msg) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(msg) ⇒ Message
Returns a new instance of Message.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rafka/message.rb', line 14 def initialize(msg) if !msg.is_a?(Array) || msg.size != 8 raise MalformedMessageError, msg end @topic = msg[1] begin @partition = Integer(msg[3]) @offset = Integer(msg[5]) rescue ArgumentError raise MalformedMessageError, msg end @value = msg[7] end |
Instance Attribute Details
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
4 5 6 |
# File 'lib/rafka/message.rb', line 4 def offset @offset end |
#partition ⇒ Object (readonly)
Returns the value of attribute partition.
4 5 6 |
# File 'lib/rafka/message.rb', line 4 def partition @partition end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
4 5 6 |
# File 'lib/rafka/message.rb', line 4 def topic @topic end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/rafka/message.rb', line 4 def value @value end |