Class: EventMachine::Kafka::ConsumerRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/em-kafka/consumer_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, topic, partition, offset, max_size) ⇒ ConsumerRequest

Returns a new instance of ConsumerRequest.



4
5
6
7
# File 'lib/em-kafka/consumer_request.rb', line 4

def initialize(type, topic, partition, offset, max_size)
  @type, @topic, @partition, @offset, @max_size =
    type, topic, partition, offset, max_size
end

Instance Method Details

#encodeObject



13
14
15
16
17
18
19
20
# File 'lib/em-kafka/consumer_request.rb', line 13

def encode
  [@type].pack("n") +
  [@topic.length].pack("n") +
  @topic +
  [@partition].pack("N") +
  [@offset].pack("Q").reverse + # DIY 64bit big endian integer
  [@max_size].pack("N")
end

#encode_sizeObject



9
10
11
# File 'lib/em-kafka/consumer_request.rb', line 9

def encode_size
  [2 + 2 + @topic.length + 4 + 8 + 4].pack("N")
end