Class: KafkaSyrup::Protocol::FetchRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/kafka_syrup/protocol/fetch_request.rb

Defined Under Namespace

Classes: Partition, Topic

Instance Attribute Summary collapse

Attributes inherited from Request

#client_id, #correlation_id

Instance Method Summary collapse

Methods inherited from Request

#api_key, #api_version, #initialize

Methods inherited from Base

#==, #config, #decode, #initialize

Methods included from Utils

#load_args, #log

Constructor Details

This class inherits a constructor from KafkaSyrup::Protocol::Request

Instance Attribute Details

#max_bytesObject

Returns the value of attribute max_bytes.



6
7
8
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 6

def max_bytes
  @max_bytes
end

#max_wait_timeObject

Returns the value of attribute max_wait_time.



6
7
8
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 6

def max_wait_time
  @max_wait_time
end

#min_bytesObject

Returns the value of attribute min_bytes.



6
7
8
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 6

def min_bytes
  @min_bytes
end

#topicsObject

Returns the value of attribute topics.



6
7
8
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 6

def topics
  @topics
end

Instance Method Details

#add_topic(name) ⇒ Object



28
29
30
31
32
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 28

def add_topic(name)
  topic = Topic.new(name, [], max_bytes)
  topics << topic
  topic
end

#defaultsObject



8
9
10
11
12
13
14
15
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 8

def defaults
  {
    max_wait_time: config.consume_max_wait_time,
    min_bytes: config.consume_min_bytes,
    max_bytes: config.consume_max_bytes,
    topics: []
  }
end

#encodeObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/kafka_syrup/protocol/fetch_request.rb', line 17

def encode
  super do
    [
      E.write_int32(REPLICA_ID),
      E.write_int32(max_wait_time),
      E.write_int32(min_bytes),
      E.write_array(topics)
    ].join
  end
end