From a14fea8cfce6c406bdf146506e1e851830e04d3b Mon Sep 17 00:00:00 2001 From: Mateus Junges Date: Sat, 17 Aug 2024 14:55:20 -0300 Subject: [PATCH 1/2] Rename method --- .phpunit.cache/test-results | 1 + src/Producers/Producer.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .phpunit.cache/test-results diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..de4d96b --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +1 @@ +{"version":1,"defects":[],"times":{"Junges\\Kafka\\Tests\\Commit\\BatchCommitterTest::testShouldCommitMessageOnlyAfterTheBatchSizeIsReached":0.029,"Junges\\Kafka\\Tests\\Commit\\BatchCommitterTest::testShouldAlwaysCommitDlq":0,"Junges\\Kafka\\Tests\\Commit\\CommitterFactoryTest::testShouldBuildAVoidCommitterWhenAutoCommitIsDisabled":0.003,"Junges\\Kafka\\Tests\\Commit\\CommitterFactoryTest::testShouldBuildARetryableBatchCommitterWhenAutoCommitIsEnabled":0.001,"Junges\\Kafka\\Tests\\Commit\\KafkaCommitterTest::testItCanCommit":0.002,"Junges\\Kafka\\Tests\\Commit\\KafkaCommitterTest::testItCanCommitToDlq":0,"Junges\\Kafka\\Tests\\Commit\\RetryableCommitterTest::testItShouldRetryToCommit":0.001,"Junges\\Kafka\\Tests\\Commit\\RetryableCommitterTest::testItShouldRetryOnlyUpToTheMaximumNumberOfRetries":0.001,"Junges\\Kafka\\Tests\\Commit\\RetryableCommitterTest::testItShouldProgressivelyWaitForTheNextRetry":0.001,"Junges\\Kafka\\Tests\\Commit\\SeekToCurrentErrorCommitterTest::testItShouldCommitOnSuccess":0.001,"Junges\\Kafka\\Tests\\Commit\\SeekToCurrentErrorCommitterTest::testItShouldNotCommitAndResubscribeOnError":0.001,"Junges\\Kafka\\Tests\\Commit\\SeekToCurrentErrorCommitterTest::testItPassesDlqCommits":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItReturnsDefaultKafkaConfiguration":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItOverrideDefaultOptionsIfUsingCustom":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItUsesSaslConfigWhenSet":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItReturnsProducerOptions":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItAcceptsCustomOptionsForProducersConfig":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testSaslCanBeUsedWithLowercaseConfigKeys":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItCreatesNullBatchConfigIfNullIsPassed":0,"Junges\\Kafka\\Tests\\Config\\ConfigTest::testItReturnsGivenBatchConfigIfInstancePassed":0.001,"Junges\\Kafka\\Tests\\Config\\SaslTest::testGetUsername":0,"Junges\\Kafka\\Tests\\Config\\SaslTest::testGetPassword":0,"Junges\\Kafka\\Tests\\Config\\SaslTest::testGetMechanisms":0,"Junges\\Kafka\\Tests\\Console\\Consumers\\KafkaConsumerCommandTest::testItCanConsumeMessages":0.067,"Junges\\Kafka\\Tests\\Console\\Consumers\\OptionsTest::testItInstantiateTheClassWithCorrectOptions":0.001,"Junges\\Kafka\\Tests\\Console\\Consumers\\OptionsTest::testItInstantiatesUsingOnlyRequiredOptions":0,"Junges\\Kafka\\Tests\\Consumers\\CallableConsumerTest::testItDecodesMessages":0.003,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItReturnsAConsumerInstance":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSubscribeToATopic":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItDoesNotSubscribeToATopicTwice":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testICanChangeDeserializersOnTheFly":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSubscribeToMoreThanOneTopicsAtOnce":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetConsumerGroupId":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItThrowsInvalidArgumentExceptionIfCreatingWithInvalidTopic":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSaveTheCommitBatchSize":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItUsesTheCorrectHandler":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetMaxMessages":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetMaxCommitRetries":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetTheDeadLetterQueue":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItUsesDlqSuffixIfDlqIsNull":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetSasl":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanAddMiddlewaresToTheHandler":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanAddInvokableClassesAsMiddleware":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetSecurityProtocol":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetSecurityProtocolViaSaslConfig":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetAutoCommit":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetStopAfterLastMessage":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSetConsumerOptions":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanSpecifyBrokersUsingWithBrokers":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCanBuildWithCustomCommitter":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerBuilderTest::testItCantCreateAConsumerWithDlqWithoutSubscribingToAnyTopics":0,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testItConsumesAMessageSuccessfullyAndCommit":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testItCanConsumeMessages":0.002,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testItCanConsumeMessagesWithQueueableHandlers":0.003,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testConsumeMessageWithError":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testCanStopConsume":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testItAcceptsCustomCommitter":0.002,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testItCanRestartConsumer":0.107,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testCanStopConsumeIfMaxTimeReached":2.009,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::testItRunCallbacksBeforeConsume":0.001,"Junges\\Kafka\\Tests\\Consumers\\ConsumerTest::it_can_test_macroed_consumers":0.001,"Junges\\Kafka\\Tests\\Handlers\\RetryableHandlerTest::testItPassesWhenNoExceptionOccurred":0.002,"Junges\\Kafka\\Tests\\Handlers\\RetryableHandlerTest::testItDoesRetriesOnException":0,"Junges\\Kafka\\Tests\\Handlers\\RetryableHandlerTest::testItBubblesExceptionWhenRetriesExceeded":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testItStorePublishedMessagesOnArray":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAssertPublished":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAssertPublishedTimes":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testItCanPerformAssertionsOnPublishedMessages":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAssertPublishedOn":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAssertPublishedOnBySpecifyingMessageObject":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAssertPublishedOnTimes":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAssertPublishedOnTimesForBatchMessages":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testICanPerformAssertionsUsingAssertPublishedOn":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testNothingPublished":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testPublishMessageBatch":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testFakeConsumer":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testFakeConsumerWithSingleMultipleMessages":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testAReceivedMessageDoesItsJob":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testStopFakeConsumer":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::testFakeBatchConsumer":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testFakeMultipleBatchConsumer":0.001,"Junges\\Kafka\\Tests\\KafkaFakeTest::testStopFakeBatchConsumer":0,"Junges\\Kafka\\Tests\\KafkaFakeTest::it_can_handle_macros":0,"Junges\\Kafka\\Tests\\KafkaTest::testItCanPublishMessagesToKafka":0.002,"Junges\\Kafka\\Tests\\KafkaTest::testICanSwitchSerializersOnTheFly":0.001,"Junges\\Kafka\\Tests\\KafkaTest::testItDoesNotSendMessagesToKafkaIfUsingFake":0,"Junges\\Kafka\\Tests\\KafkaTest::testICanSetTheEntireMessageWithMessageObject":0.001,"Junges\\Kafka\\Tests\\KafkaTest::testICanDisableDebugUsingWithDebugDisabledMethod":0.005,"Junges\\Kafka\\Tests\\KafkaTest::testICanUseCustomOptionsForProducerConfig":0,"Junges\\Kafka\\Tests\\KafkaTest::testCreateConsumerReturnsAConsumerBuilderInstance":0,"Junges\\Kafka\\Tests\\KafkaTest::testCreateConsumerDefaultConfigs":0,"Junges\\Kafka\\Tests\\KafkaTest::testProducerThrowsExceptionIfMessageCouldNotBePublished":0.946,"Junges\\Kafka\\Tests\\KafkaTest::testSendMessageBatch":0.001,"Junges\\Kafka\\Tests\\KafkaTest::testMacro":0,"Junges\\Kafka\\Tests\\KafkaTest::it_stores_published_messages_when_using_macros":0,"Junges\\Kafka\\Tests\\Message\\Deserializers\\AvroDeserializerTest::testDeserializeTombstone":0.003,"Junges\\Kafka\\Tests\\Message\\Deserializers\\AvroDeserializerTest::testDeserializeWithSchema":0.006,"Junges\\Kafka\\Tests\\Message\\Deserializers\\AvroDeserializerTest::testDeserializeKeyMode":0.001,"Junges\\Kafka\\Tests\\Message\\Deserializers\\AvroDeserializerTest::testDeserializeBodyMode":0.001,"Junges\\Kafka\\Tests\\Message\\Deserializers\\AvroDeserializerTest::testGetRegistry":0,"Junges\\Kafka\\Tests\\Message\\Deserializers\\JsonDeserializerTest::testDeserialize":0.001,"Junges\\Kafka\\Tests\\Message\\Deserializers\\JsonDeserializerTest::testDeserializeNonJson":0,"Junges\\Kafka\\Tests\\Message\\KafkaAvroSchemaTest::testGetters":0,"Junges\\Kafka\\Tests\\Message\\KafkaAvroSchemaTest::testSetters":0,"Junges\\Kafka\\Tests\\Message\\KafkaAvroSchemaTest::testAvroSchemaWithJustName":0,"Junges\\Kafka\\Tests\\Message\\MessageTest::testItCanSetAMessageKey":0,"Junges\\Kafka\\Tests\\Message\\MessageTest::testItCanForgetAMessageKey":0,"Junges\\Kafka\\Tests\\Message\\MessageTest::testItCanSetMessageHeaders":0,"Junges\\Kafka\\Tests\\Message\\MessageTest::testItCanSetTheMessageKey":0,"Junges\\Kafka\\Tests\\Message\\MessageTest::testItCanGetTheMessagePayload":0,"Junges\\Kafka\\Tests\\Message\\MessageTest::testItCanTransformAMessageInArray":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testAddBodySchemaMappingForTopic":0.002,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testAddKeySchemaMappingForTopic":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testHasBodySchemaMappingForTopic":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testHasKeySchemaMappingForTopic":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testGetBodySchemaForTopicWithNoMapping":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testGetBodySchemaForTopicWithMappingWithDefinition":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testGetKeySchemaForTopicWithMappingWithDefinition":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testGetBodySchemaForTopicWithMappingWithoutDefinitionLatest":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testGetBodySchemaForTopicWithMappingWithoutDefinitionVersion":0,"Junges\\Kafka\\Tests\\Message\\Registry\\AvroSchemaRegistryTest::testGetTopicSchemaMapping":0,"Junges\\Kafka\\Tests\\Message\\Serializers\\AvroSerializerTest::testSerializeTombstone":0.001,"Junges\\Kafka\\Tests\\Message\\Serializers\\AvroSerializerTest::testSerializeWithoutSchemaDefinition":0.001,"Junges\\Kafka\\Tests\\Message\\Serializers\\AvroSerializerTest::testSerializeSuccessWithSchema":0.001,"Junges\\Kafka\\Tests\\Message\\Serializers\\AvroSerializerTest::testSerializeKeyMode":0.001,"Junges\\Kafka\\Tests\\Message\\Serializers\\AvroSerializerTest::testSerializeBodyMode":0.001,"Junges\\Kafka\\Tests\\Message\\Serializers\\AvroSerializerTest::testGetRegistry":0,"Junges\\Kafka\\Tests\\Message\\Serializers\\JsonSerializerTest::testSerialize":0.003,"Junges\\Kafka\\Tests\\Message\\Serializers\\JsonSerializerTest::testSerializeThrowsException":0,"Junges\\Kafka\\Tests\\Producers\\ProducerTest::testItDoesNotDoubleSerializeMessageWhenUsingJsonSerializer":0.001}} \ No newline at end of file diff --git a/src/Producers/Producer.php b/src/Producers/Producer.php index 2d1b006..e9de95c 100644 --- a/src/Producers/Producer.php +++ b/src/Producers/Producer.php @@ -36,13 +36,13 @@ public function __construct( private readonly MessageSerializer $serializer, ) { $this->producer = app(KafkaProducer::class, [ - 'conf' => $this->setConf($this->config->getProducerOptions()), + 'conf' => $this->getConf($this->config->getProducerOptions()), ]); $this->dispatcher = App::make(Dispatcher::class); } /** Set the Kafka Configuration. */ - private function setConf(array $options): Conf + private function getConf(array $options): Conf { $conf = new Conf(); From 5fa0f1ba061ad9ad50ac36e5708ec6dd4a216e0d Mon Sep 17 00:00:00 2001 From: Mateus Junges Date: Sat, 17 Aug 2024 22:20:37 -0300 Subject: [PATCH 2/2] Add return types --- src/Providers/LaravelKafkaServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Providers/LaravelKafkaServiceProvider.php b/src/Providers/LaravelKafkaServiceProvider.php index aecd809..bd5355c 100644 --- a/src/Providers/LaravelKafkaServiceProvider.php +++ b/src/Providers/LaravelKafkaServiceProvider.php @@ -32,7 +32,7 @@ public function boot(): void } } - public function register() + public function register(): void { $this->app->bind(MessageSerializer::class, fn () => new JsonSerializer()); @@ -47,7 +47,7 @@ public function register() $this->app->singleton(LoggerContract::class, Logger::class); } - private function publishesConfiguration() + private function publishesConfiguration(): void { $this->publishes([ __DIR__."/../../config/kafka.php" => config_path('kafka.php'),