Class: Rdkafka::Consumer::Message
- Inherits:
-
Object
- Object
- Rdkafka::Consumer::Message
- Defined in:
- lib/rdkafka/consumer/message.rb
Overview
A message that was consumed from a topic.
Instance Attribute Summary collapse
-
#key ⇒ String?
readonly
This message's key.
-
#offset ⇒ Integer
readonly
This message's offset in it's partition.
-
#partition ⇒ Integer
readonly
The partition this message was consumed from.
-
#payload ⇒ String?
readonly
This message's payload.
-
#timestamp ⇒ Integer?
readonly
This message's timestamp, if provided by the broker.
-
#topic ⇒ String
readonly
The topic this message was consumed from.
Instance Method Summary collapse
-
#to_s ⇒ String
Human readable representation of this message.
- #truncate(string) ⇒ Object
Instance Attribute Details
#key ⇒ String? (readonly)
This message's key
19 20 21 |
# File 'lib/rdkafka/consumer/message.rb', line 19 def key @key end |
#offset ⇒ Integer (readonly)
This message's offset in it's partition
23 24 25 |
# File 'lib/rdkafka/consumer/message.rb', line 23 def offset @offset end |
#partition ⇒ Integer (readonly)
The partition this message was consumed from
11 12 13 |
# File 'lib/rdkafka/consumer/message.rb', line 11 def partition @partition end |
#payload ⇒ String? (readonly)
This message's payload
15 16 17 |
# File 'lib/rdkafka/consumer/message.rb', line 15 def payload @payload end |
#timestamp ⇒ Integer? (readonly)
This message's timestamp, if provided by the broker
27 28 29 |
# File 'lib/rdkafka/consumer/message.rb', line 27 def @timestamp end |
#topic ⇒ String (readonly)
The topic this message was consumed from
7 8 9 |
# File 'lib/rdkafka/consumer/message.rb', line 7 def topic @topic end |
Instance Method Details
#to_s ⇒ String
Human readable representation of this message.
47 48 49 |
# File 'lib/rdkafka/consumer/message.rb', line 47 def to_s "<Message in '#{topic}' with key '#{truncate(key)}', payload '#{truncate(payload)}', partition #{partition}, offset #{offset}, timestamp #{}>" end |
#truncate(string) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/rdkafka/consumer/message.rb', line 51 def truncate(string) if string && string.length > 40 "#{string[0..39]}..." else string end end |