Skip to content

Commit a7c159e

Browse files
committed
Ignore validate_only field
1 parent 6024981 commit a7c159e

File tree

4 files changed

+10
-25
lines changed

4 files changed

+10
-25
lines changed

lib/kafka/client.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,10 @@ def delete_topic(name, timeout: 30)
479479
# @param num_partitions [Integer] the number of desired partitions for
480480
# the topic
481481
# @param timeout [Integer] a duration of time to wait for the new
482-
# @param validate_only [Boolean] whether this request is to validate only
483-
# without actually execute it
484482
# partitions to be added.
485483
# @return [nil]
486-
def create_partitions_for(name, num_partitions: 1, timeout: 30, validate_only: false)
487-
@cluster.create_partitions_for(name, num_partitions: num_partitions, timeout: timeout, validate_only: validate_only)
484+
def create_partitions_for(name, num_partitions: 1, timeout: 30)
485+
@cluster.create_partitions_for(name, num_partitions: num_partitions, timeout: timeout)
488486
end
489487

490488
# Lists all topics in the cluster.

lib/kafka/cluster.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,10 @@ def delete_topic(name, timeout:)
210210
@logger.info "Topic `#{name}` was deleted"
211211
end
212212

213-
def create_partitions_for(name, num_partitions:, timeout:, validate_only:)
214-
assignments = nil
213+
def create_partitions_for(name, num_partitions:, timeout:)
215214
options = {
216-
topics: [[name, num_partitions, assignments]],
217-
timeout: timeout,
218-
validate_only: validate_only
215+
topics: [[name, num_partitions, nil]],
216+
timeout: timeout
219217
}
220218

221219
broker = controller_broker

lib/kafka/protocol/create_partitions_request.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module Kafka
22
module Protocol
33

44
class CreatePartitionsRequest
5-
def initialize(topics:, timeout:, validate_only:)
6-
@topics, @timeout, @validate_only = topics, timeout, validate_only
5+
def initialize(topics:, timeout:)
6+
@topics, @timeout = topics, timeout
77
end
88

99
def api_key
@@ -30,7 +30,9 @@ def encode(encoder)
3030
end
3131
# Timeout is in ms.
3232
encoder.write_int32(@timeout * 1000)
33-
encoder.write_boolean(@validate_only)
33+
# validate_only. There isn't any use case for this in real life. So
34+
# let's ignore it for now
35+
encoder.write_boolean(false)
3436
end
3537
end
3638

spec/functional/topic_management_spec.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,4 @@
3232
kafka.create_partitions_for(topic, num_partitions: 10)
3333
expect(kafka.partitions_for(topic)).to eq 10
3434
end
35-
36-
example "validate partition creation" do
37-
unless kafka.supports_api?(Kafka::Protocol::CREATE_PARTITIONS_API)
38-
skip("This Kafka version not support ")
39-
end
40-
topic = generate_topic_name
41-
42-
kafka.create_topic(topic, num_partitions: 3)
43-
expect(kafka.partitions_for(topic)).to eq 3
44-
45-
kafka.create_partitions_for(topic, num_partitions: 10, validate_only: true)
46-
expect(kafka.partitions_for(topic)).to eq 3
47-
end
4835
end

0 commit comments

Comments
 (0)