Skip to content

Commit 9e43522

Browse files
authored
Merge pull request #485 from zendesk/dasch/refactor-create-topic
Improve the topic creation API
2 parents 9fb4005 + 62a2c5c commit 9e43522

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/kafka/client.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,18 @@ def each_message(topic:, start_from_beginning: true, max_wait_time: 5, min_bytes
451451
end
452452
end
453453

454-
def create_topic(name, **options)
455-
@cluster.create_topic(name, **options)
454+
# Creates a topic in the cluster.
455+
#
456+
# @param name [String] the name of the topic.
457+
# @param num_partitions [Integer] the number of partitions that should be created
458+
# in the topic.
459+
# @param replication_factor [Integer] the replication factor of the topic.
460+
# @param timeout [Integer] a duration of time to wait for the topic to be
461+
# completely created.
462+
# @raise [Kafka::TopicAlreadyExists] if the topic already exists.
463+
# @return [nil]
464+
def create_topic(name, num_partitions: 1, replication_factor: 1, timeout: 30)
465+
@cluster.create_topic(name, num_partitions: num_partitions, replication_factor: replication_factor, timeout: timeout)
456466
end
457467

458468
# Lists all topics in the cluster.

lib/kafka/cluster.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def partitions_for(topic)
145145
raise
146146
end
147147

148-
def create_topic(name, num_partitions: 1, replication_factor: 1, timeout: 30)
148+
def create_topic(name, num_partitions:, replication_factor:, timeout:)
149149
options = {
150150
topics: {
151151
name => {

0 commit comments

Comments
 (0)