Skip to content

[Messenger] Kafka Transport Bridge #51070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: 7.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleaned up docblocks
  • Loading branch information
andythorne committed Aug 14, 2023
commit 9622b677f814afb2178255f6a51a7ab7092d95b9
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class Connection
private KafkaFactory $kafkaFactory;

/**
* @psalm-param array{topics: list<string>, consume_timeout_ms: int, commit_async: bool, conf_options: array<string, string>} $consumerConfig
* @psalm-param array{topic: string, poll_timeout_ms: int, flush_timeout_ms: int, conf_options: array<string, string>} $producerConfig
* @param array{topics: list<string>, consume_timeout_ms: int, commit_async: bool, conf_options: array<string, string>} $consumerConfig
* @param array{topic: string, poll_timeout_ms: int, flush_timeout_ms: int, conf_options: array<string, string>} $producerConfig
*/
private function __construct(
private readonly array $consumerConfig,
Expand Down Expand Up @@ -108,7 +108,9 @@ public static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
);
}

/** @psalm-param array<string, bool|float|int|string|array<string>> $configOptions */
/**
* @param array<string, bool|float|int|string|array<string>> $configOptions
*/
private static function setupConsumerOptions(string $brokerList, array $configOptions): array
{
if (0 === \count($configOptions)) {
Expand Down Expand Up @@ -151,7 +153,9 @@ private static function setupConsumerOptions(string $brokerList, array $configOp
return $options;
}

/** @psalm-param array<string, bool|float|int|string|array<string>> $configOptions */
/**
* @param array<string, bool|float|int|string|array<string>> $configOptions
*/
private static function setupProducerOptions(string $brokerList, array $configOptions): array
{
if (0 === \count($configOptions)) {
Expand Down Expand Up @@ -276,7 +280,9 @@ public function ack(Message $message): void
}
}

/** @psalm-param array<string, string> $headers */
/**
* @param array<string, string> $headers
*/
public function publish(int $partition, int $messageFlags, string $body, string $key = null, array $headers = []): void
{
if (!$this->producerConfig['topic']) {
Expand All @@ -285,7 +291,6 @@ public function publish(int $partition, int $messageFlags, string $body, string

$producer = $this->getProducer();

/** @psalm-var \RdKafka\ProducerTopic $topic */
$topic = $producer->newTopic($this->producerConfig['topic']);
$topic->producev(
$partition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function __construct(
) {
}

/** @psalm-param array<string, string> $kafkaConfig */
/**
* @param array<string, string> $kafkaConfig
*/
public function createConsumer(array $kafkaConfig): KafkaConsumer
{
$conf = $this->getBaseConf();
Expand All @@ -55,7 +57,9 @@ public function createConsumer(array $kafkaConfig): KafkaConsumer
return new KafkaConsumer($conf);
}

/** @psalm-param array<string, string> $kafkaConfig */
/**
* @param array<string, string> $kafkaConfig
*/
public function createProducer(array $kafkaConfig): Producer
{
$conf = $this->getBaseConf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
namespace Symfony\Component\Messenger\Bridge\Kafka\Transport;

/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @see https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md
*/
final class KafkaOption
{
/** @psalm-return array<string, string> */
/**
* @return array<string, string>
*/
public static function consumer(): array
{
return array_merge(
Expand Down Expand Up @@ -59,7 +59,9 @@ public static function consumer(): array
);
}

/** @psalm-return array<string, string> */
/**
* @return array<string, string>
*/
public static function producer(): array
{
return array_merge(
Expand Down Expand Up @@ -100,7 +102,9 @@ public static function producer(): array
);
}

/** @psalm-return array<string, string> */
/**
* @return array<string, string>
*/
public static function global(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function __construct(
) {
}

/** @psalm-return \Traversable<Envelope> */
public function get(): iterable
{
yield from $this->getEnvelope();
Expand Down