Skip to content

Commit

Permalink
Merge pull request #23 from sts-gaming-group/dev
Browse files Browse the repository at this point in the history
Merge dev to master
  • Loading branch information
wowo authored Jan 24, 2025
2 parents 76a5f8a + 005fad9 commit 960109f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 40 deletions.
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1.0",
"ext-rdkafka": "*",
"ext-json": "*",
"symfony/config": "^4.3.3|^5.0|^6.0|^7.0",
"symfony/dependency-injection": "^4.3.3|^5.2|^6.0|^7.0",
"symfony/http-kernel": "^4.3|^5.2.1|^6.0|^7.0",
"symfony/console": "^4.0|^5.2.0|^6.0|^7.0",
"symfony/options-resolver": "~4.3|^5.2|^6.0|^7.0",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/console": "^6.4|^7.0",
"symfony/options-resolver": "^6.4|^7.0",
"flix-tech/avro-serde-php": "^2.0"
},
"autoload": {
Expand All @@ -31,14 +31,14 @@
}
},
"require-dev": {
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
"symfony/dotenv": "5.2.*|^6.0|^7.0",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/dotenv": "^6.4|^7.0",
"phpstan/phpstan": "^0.12.75|^1.12",
"phpstan/phpstan-symfony": "^0.12.18|^1.4",
"phpstan/phpstan-phpunit": "^0.12.17|^1.4",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/extension-installer": "^1.1",
"symfony/framework-bundle": "^5.2|^6.0|^7.0",
"symfony/event-dispatcher": "^5.2|^6.0|^7.0"
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0"
}
}
22 changes: 10 additions & 12 deletions src/Command/ConsumeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@
use StsGamingGroup\KafkaBundle\Configuration\ConfigurationResolver;
use StsGamingGroup\KafkaBundle\Configuration\RawConfiguration;
use StsGamingGroup\KafkaBundle\Traits\AddConfigurationsToCommandTrait;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'kafka:consumers:consume',
description: 'Starts consuming messages from kafka using class implementing '.ConsumerInterface::class
)]
class ConsumeCommand extends Command
{
use AddConfigurationsToCommandTrait;
use DescribeTrait;

protected static $defaultName = 'kafka:consumers:consume';

private RawConfiguration $rawConfiguration;
private ConsumerProvider $consumerProvider;
private ConsumerClient $consumerClient;
Expand All @@ -45,14 +48,9 @@ public function __construct(

protected function configure(): void
{
$this->setDescription(
sprintf(
'Starts consuming messages from kafka using class implementing %s.',
ConsumerInterface::class
)
)
->addArgument('name', InputArgument::REQUIRED, 'Name of the registered consumer.')
->addOption('describe', null, InputOption::VALUE_NONE, 'Describes consumer');
$this
->addArgument(name: 'name', mode: InputArgument::REQUIRED, description: 'Name of the registered consumer.')
->addOption(name: 'describe', mode: InputOption::VALUE_NONE, description: 'Describes consumer');

$this->addConfigurations($this->rawConfiguration);
}
Expand All @@ -64,11 +62,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($input->getOption('describe')) {
$this->describe($this->configurationResolver->resolve($consumer, $input), $output, $consumer);

return 0;
return self::SUCCESS;
}

$this->consumerClient->consume($consumer, $input);

return 0;
return self::SUCCESS;
}
}
17 changes: 11 additions & 6 deletions src/Command/ConsumersDescribeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
use StsGamingGroup\KafkaBundle\Client\Consumer\ConsumerProvider;
use StsGamingGroup\KafkaBundle\Command\Traits\DescribeTrait;
use StsGamingGroup\KafkaBundle\Configuration\ConfigurationResolver;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'kafka:consumers:describe',
description: 'Show consumers configuration.'
)]
class ConsumersDescribeCommand extends Command
{
use DescribeTrait;

protected static $defaultName = 'kafka:consumers:describe';

private ConsumerProvider $consumerProvider;
private ConfigurationResolver $configurationResolver;

Expand All @@ -33,9 +36,11 @@ public function __construct(

protected function configure(): void
{
$this
->setDescription('Show consumers configuration.')
->addOption('name', null, InputOption::VALUE_REQUIRED, 'Shows specific consumer configuration.');
$this->addOption(
name: 'name',
mode: InputOption::VALUE_REQUIRED,
description: 'Shows specific consumer configuration.'
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand All @@ -47,6 +52,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->describe($this->configurationResolver->resolve($consumer), $output, $consumer);
}

return 0;
return self::SUCCESS;
}
}
14 changes: 6 additions & 8 deletions src/Command/ProducersDescribeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
use StsGamingGroup\KafkaBundle\Client\Producer\ProducerProvider;
use StsGamingGroup\KafkaBundle\Command\Traits\DescribeTrait;
use StsGamingGroup\KafkaBundle\Configuration\ConfigurationResolver;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'kafka:producers:describe',
description: 'Show producers configuration.'
)]
class ProducersDescribeCommand extends Command
{
use DescribeTrait;

protected static $defaultName = 'kafka:producers:describe';

private ProducerProvider $producerProvider;
private ConfigurationResolver $configurationResolver;

Expand All @@ -30,11 +33,6 @@ public function __construct(
parent::__construct();
}

protected function configure(): void
{
$this->setDescription('Show producers configuration.');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$producers = $this->producerProvider->getProducers();
Expand All @@ -43,6 +41,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->describe($this->configurationResolver->resolve($producer), $output, $producer);
}

return 0;
return self::SUCCESS;
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Client/Consumer/ConsumerProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testMultipleConsumersFound(): void
->addConsumer($this->consumerTwo);

$this->expectException(InvalidConsumerException::class);
$this->expectErrorMessageMatches('/Multiple consumers/');
$this->expectExceptionMessageMatches('/Multiple consumers/');
$this->consumerProvider->provide('consumer_2');
}

Expand All @@ -62,7 +62,7 @@ public function testNoConsumerFound(): void
->addConsumer($this->consumerTwo);

$this->expectException(InvalidConsumerException::class);
$this->expectErrorMessageMatches('/no matching consumer/');
$this->expectExceptionMessageMatches('/no matching consumer/');
$this->consumerProvider->provide('consumer_3');
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Configuration/ConfigurationResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function testInputValueInvalid(): void
$resolver = new ConfigurationResolver($rawConfiguration, $this->yamlConfig);

$this->expectException(InvalidConfigurationException::class);
$this->expectDeprecationMessageMatches('/configuration_one/');
$this->expectExceptionMessageMatches('/configuration_one/');

$resolver->resolve(DummyConsumerOne::class, $this->input);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testYamlConfigInvalid(): void
$resolver = new ConfigurationResolver($rawConfiguration, $this->yamlConfig);

$this->expectException(InvalidConfigurationException::class);
$this->expectDeprecationMessageMatches('/group_id/');
$this->expectExceptionMessageMatches('/group_id/');

$resolver->resolve(DummyConsumerOne::class);
}
Expand Down

0 comments on commit 960109f

Please sign in to comment.