From f2905e8a1f5f180248b0b6c340912798c6b7402a Mon Sep 17 00:00:00 2001 From: Mateus Junges Date: Wed, 14 Feb 2024 20:09:03 -0300 Subject: [PATCH] Rename producer builder to builder --- docs/producing-messages/5-publishing-to-kafka.md | 2 +- .../6-producing-message-batch-to-kafka.md | 2 +- src/Contracts/MessageProducer.php | 4 +--- src/Factory.php | 4 ++-- src/Producers/{ProducerBuilder.php => Builder.php} | 4 ++-- tests/KafkaTest.php | 6 +++--- 6 files changed, 10 insertions(+), 12 deletions(-) rename src/Producers/{ProducerBuilder.php => Builder.php} (98%) diff --git a/docs/producing-messages/5-publishing-to-kafka.md b/docs/producing-messages/5-publishing-to-kafka.md index 9a208a0f..83f322cf 100644 --- a/docs/producing-messages/5-publishing-to-kafka.md +++ b/docs/producing-messages/5-publishing-to-kafka.md @@ -8,7 +8,7 @@ After configuring all your message options, you must use the send method, to sen ```php use Junges\Kafka\Facades\Kafka; -/** @var \Junges\Kafka\Producers\ProducerBuilder $producer */ +/** @var \Junges\Kafka\Producers\Builder $producer */ $producer = Kafka::publishOn('topic') ->withConfigOptions(['key' => 'value']) ->withKafkaKey('kafka-key') diff --git a/docs/producing-messages/6-producing-message-batch-to-kafka.md b/docs/producing-messages/6-producing-message-batch-to-kafka.md index c62928de..c79a8be8 100644 --- a/docs/producing-messages/6-producing-message-batch-to-kafka.md +++ b/docs/producing-messages/6-producing-message-batch-to-kafka.md @@ -26,7 +26,7 @@ $messageBatch->push($message); $messageBatch->push($message); $messageBatch->push($message); -/** @var \Junges\Kafka\Producers\ProducerBuilder $producer */ +/** @var \Junges\Kafka\Producers\Builder $producer */ $producer = Kafka::publishOn('topic') ->withConfigOptions(['key' => 'value']); diff --git a/src/Contracts/MessageProducer.php b/src/Contracts/MessageProducer.php index fd15f3ec..6317ce75 100644 --- a/src/Contracts/MessageProducer.php +++ b/src/Contracts/MessageProducer.php @@ -8,9 +8,7 @@ use Junges\Kafka\Producers\Producer; use Junges\Kafka\Support\Testing\Fakes\ProducerFake; -/** - * @internal - */ +/** @internal */ interface MessageProducer extends InteractsWithConfigCallbacks { /** Return a new Junges\Commit\ProducerBuilder instance. */ diff --git a/src/Factory.php b/src/Factory.php index d0840292..0ef4d64f 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -6,7 +6,7 @@ use Junges\Kafka\Consumers\ConsumerBuilder; use Junges\Kafka\Contracts\KafkaManager; use Junges\Kafka\Contracts\MessageProducer; -use Junges\Kafka\Producers\ProducerBuilder; +use Junges\Kafka\Producers\Builder; class Factory implements KafkaManager { @@ -15,7 +15,7 @@ class Factory implements KafkaManager /** Creates a new ProducerBuilder instance, setting brokers and topic. */ public function publish(string $broker = null): MessageProducer { - return new ProducerBuilder( + return new Builder( broker: $broker ?? config('kafka.brokers') ); } diff --git a/src/Producers/ProducerBuilder.php b/src/Producers/Builder.php similarity index 98% rename from src/Producers/ProducerBuilder.php rename to src/Producers/Builder.php index caed0375..1a601543 100644 --- a/src/Producers/ProducerBuilder.php +++ b/src/Producers/Builder.php @@ -10,7 +10,7 @@ use Junges\Kafka\Contracts\MessageSerializer; use Junges\Kafka\Contracts\ProducerMessage; -class ProducerBuilder implements MessageProducer +class Builder implements MessageProducer { use InteractsWithConfigCallbacks; use Conditionable; @@ -38,7 +38,7 @@ public function __construct( /** Return a new Junges\Commit\ProducerBuilder instance. */ public static function create(string $broker = null): self { - return new ProducerBuilder( + return new Builder( broker: $broker ?? config('kafka.brokers') ); } diff --git a/tests/KafkaTest.php b/tests/KafkaTest.php index 9c5ef547..69c683c5 100644 --- a/tests/KafkaTest.php +++ b/tests/KafkaTest.php @@ -17,7 +17,7 @@ use Junges\Kafka\Message\Message; use Junges\Kafka\Message\Serializers\JsonSerializer; use Junges\Kafka\Producers\MessageBatch; -use Junges\Kafka\Producers\ProducerBuilder; +use Junges\Kafka\Producers\Builder; use Mockery as m; use RdKafka\Producer; use RdKafka\ProducerTopic; @@ -193,7 +193,7 @@ public function testICanDisableDebugUsingWithDebugDisabledMethod(): void return $mockedProducer; }); - /** @var ProducerBuilder $producer */ + /** @var Builder $producer */ $producer = Kafka::publish() ->withConfigOptions([ 'metadata.broker.list' => 'broker', @@ -343,7 +343,7 @@ public function testMacro(): void $producer = Kafka::defaultProducer(); - $this->assertInstanceOf(ProducerBuilder::class, $producer); + $this->assertInstanceOf(Builder::class, $producer); $this->assertEquals($sasl, $this->getPropertyWithReflection('saslConfig', $producer)); } }