Skip to content

Commit

Permalink
chore: remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hcdias committed Oct 17, 2023
1 parent 10721cd commit 97f2e19
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
43 changes: 0 additions & 43 deletions src/Connectors/Producer/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace Metamorphosis\Connectors\Producer;

use Metamorphosis\AbstractConfigManager;
use Metamorphosis\Connectors\AbstractConfig;
use Metamorphosis\Exceptions\ConfigurationException;
use Metamorphosis\ProducerConfigManager;
use Metamorphosis\TopicHandler\ConfigOptions\Producer as ProducerConfigOptions;

class Config extends AbstractConfig
{
Expand Down Expand Up @@ -38,43 +34,4 @@ class Config extends AbstractConfig
'partition' => RD_KAFKA_PARTITION_UA,
'ssl_verify' => false,
];

public function make(ProducerConfigOptions $configOptions): AbstractConfigManager
{
$configManager = app(ProducerConfigManager::class);
$configManager->set($configOptions->toArray());

return $configManager;
}

public function makeByTopic(string $topicId): AbstractConfigManager
{
$topicConfig = $this->getTopicConfig($topicId);
$topicConfig['middlewares'] = $topicConfig['producer']['middlewares'] ?? [];
$brokerConfig = $this->getBrokerConfig('service');
$schemaConfig = $this->getSchemaConfig('service');
$config = array_merge($topicConfig, $brokerConfig, $schemaConfig);

$this->validate($config);
$config = array_merge($this->default, $config);

$configManager = app(ProducerConfigManager::class);
$configManager->set($config);

return $configManager;
}

private function getTopicConfig(string $topicId): array
{
$topicConfig = array_merge(
config('kafka.topics.' . $topicId, []),
config('kafka.topics.' . $topicId . '.producer', [])
);
if (!$topicConfig) {
throw new ConfigurationException("Topic '{$topicId}' not found");
}
$topicConfig['topic'] = $topicId;

return $topicConfig;
}
}
10 changes: 0 additions & 10 deletions src/Producer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Metamorphosis\Middlewares\Handler\Producer as ProducerMiddleware;
use Metamorphosis\Producer\Poll;
use Metamorphosis\TopicHandler\ConfigOptions\Producer as ProducerConfigOptions;
use Metamorphosis\TopicHandler\Producer\AbstractProducer;
use Metamorphosis\TopicHandler\Producer\HandlerInterface;

class Producer
Expand Down Expand Up @@ -73,13 +72,4 @@ public function getProducerMiddleware(
compact('topic', 'poll', 'partition')
);
}

private function getConfigManager(HandlerInterface $producerHandler): AbstractConfigManager
{
if ($producerHandler instanceof AbstractProducer) {
return $this->config->make($producerHandler->getConfigOptions());
}

return $this->config->makeByTopic($producerHandler->getTopic());
}
}

0 comments on commit 97f2e19

Please sign in to comment.