Skip to content

Commit

Permalink
Make brokers optional on publishOn and createConsumer methods. If not…
Browse files Browse the repository at this point in the history
… informed, the config default will be used.
  • Loading branch information
mateusjunges committed Nov 12, 2021
1 parent fe19922 commit 5117cd8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Kafka.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ class Kafka implements CanPublishMessagesToKafka
/**
* Creates a new ProducerBuilder instance, setting brokers and topic.
*
* @param string $broker
* @param string|null $broker
* @param string $topic
* @return CanProduceMessages
*/
public function publishOn(string $broker, string $topic): CanProduceMessages
public function publishOn(string $topic, string $broker = null): CanProduceMessages
{
return new ProducerBuilder(
broker: $broker,
topic: $topic
topic: $topic,
broker: $broker ?? config('kafka.brokers')
);
}

/**
* Return a ConsumerBuilder instance.
*
* @param string $brokers
* @param array $topics
* @param string|null $groupId
* @param string|null $brokers
* @return \Junges\Kafka\Consumers\ConsumerBuilder
*/
public function createConsumer(string $brokers, array $topics = [], string $groupId = null): ConsumerBuilder
public function createConsumer(array $topics = [], string $groupId = null, string $brokers = null): ConsumerBuilder
{
return ConsumerBuilder::create(
brokers: $brokers,
brokers: $brokers ?? config('kafka.brokers'),
topics: $topics,
groupId: $groupId
);
Expand Down

0 comments on commit 5117cd8

Please sign in to comment.