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 its 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)
Returns a message headers.
      32 33 34  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 32 def headers @headers end  | 
  
#key ⇒ String? (readonly)
This message’s key
      21 22 23  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 21 def key @key end  | 
  
#offset ⇒ Integer (readonly)
This message’s offset in its partition
      25 26 27  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 25 def offset @offset end  | 
  
#partition ⇒ Integer (readonly)
The partition this message was consumed from
      13 14 15  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 13 def partition @partition end  | 
  
#payload ⇒ String? (readonly)
This message’s payload
      17 18 19  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 17 def payload @payload end  | 
  
#timestamp ⇒ Time? (readonly)
This message’s timestamp, if provided by the broker
      29 30 31  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 29 def @timestamp end  | 
  
#topic ⇒ String (readonly)
The topic this message was consumed from
      9 10 11  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 9 def topic @topic end  | 
  
Instance Method Details
#to_s ⇒ String
Human readable representation of this message.
      68 69 70 71 72  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 68 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 #{}#{is_headers}>" end  | 
  
#truncate(string) ⇒ Object
      74 75 76 77 78 79 80  | 
    
      # File 'lib/rdkafka/consumer/message.rb', line 74 def truncate(string) if string && string.length > 40 "#{string[0..39]}..." else string end end  |