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
-
#headers ⇒ Hash<String, String>
readonly
A message headers.
-
#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 ⇒ Time?
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
#headers ⇒ Hash<String, String> (readonly)
30 31 32 |
# File 'lib/rdkafka/consumer/message.rb', line 30 def headers @headers end |
#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 ⇒ Time? (readonly)
This message's timestamp, if provided by the broker
27 28 29 |
# File 'lib/rdkafka/consumer/message.rb', line 27 def 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.
66 67 68 69 70 |
# File 'lib/rdkafka/consumer/message.rb', line 66 def to_s is_headers = @headers.empty? ? "" : ", headers #{headers.size}" "<Message in '#{topic}' with key '#{truncate(key)}', payload '#{truncate(payload)}', partition #{partition}, offset #{offset}, timestamp #{timestamp}#{is_headers}>" end |
#truncate(string) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/rdkafka/consumer/message.rb', line 72 def truncate(string) if string && string.length > 40 "#{string[0..39]}..." else string end end |