改名
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
|
||||
+6
-26
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
|
||||
use RdKafka\Conf;
|
||||
use RdKafka\Consumer;
|
||||
use RdKafka\ConsumerTopic;
|
||||
use RdKafka\Exception;
|
||||
use RdKafka\KafkaConsumer;
|
||||
@@ -16,8 +17,7 @@ use Swoole\Coroutine\Channel;
|
||||
use Swoole\Coroutine\WaitGroup;
|
||||
use Swoole\Process;
|
||||
use Snowflake\Abstracts\Config as SConfig;
|
||||
use Swoole\Timer;
|
||||
use function Amp\stop;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class Queue
|
||||
@@ -29,26 +29,6 @@ class Kafka extends \Snowflake\Process\Process
|
||||
protected Channel $channel;
|
||||
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
*/
|
||||
// public function initConfig()
|
||||
// {
|
||||
// $kafka = SConfig::get('kafka');
|
||||
// $config = ConsumerConfig::getInstance();
|
||||
// $config->setMetadataRefreshIntervalMs(
|
||||
// $kafka['metadataRefreshIntervalMs'] ?? 1000
|
||||
// );
|
||||
// $config->setMetadataBrokerList($kafka['brokers']);
|
||||
// $config->setGroupId($kafka['groupId']);
|
||||
// $config->setBrokerVersion($kafka['version']);
|
||||
// $config->setTopics($kafka['topics']);
|
||||
// $this->channelListener($kafka);
|
||||
//
|
||||
// return [new Consumer(), $kafka];
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @param Process $process
|
||||
* @throws ConfigException
|
||||
@@ -79,7 +59,7 @@ class Kafka extends \Snowflake\Process\Process
|
||||
private function waite(array $kafkaServer)
|
||||
{
|
||||
[$config, $topic, $conf] = $this->kafkaConfig($kafkaServer);
|
||||
$objRdKafka = new \RdKafka\Consumer($config);
|
||||
$objRdKafka = new Consumer($config);
|
||||
$topic = $objRdKafka->newTopic($kafkaServer['topic'], $topic);
|
||||
$topic->consumeStart(0, RD_KAFKA_OFFSET_STORED);
|
||||
while (true) {
|
||||
@@ -108,7 +88,7 @@ class Kafka extends \Snowflake\Process\Process
|
||||
} else {
|
||||
$this->application->error($message->errstr());
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
} catch (Throwable $exception) {
|
||||
$this->application->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -154,7 +134,7 @@ class Kafka extends \Snowflake\Process\Process
|
||||
return;
|
||||
}
|
||||
$class->onHandler(new Struct($topic, $message));
|
||||
} catch (\Throwable $exception) {
|
||||
} catch (Throwable $exception) {
|
||||
$this->application->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
||||
// +---------------------------------------------------------------------------
|
||||
// | SWAN [ $_SWANBR_SLOGAN_$ ]
|
||||
// +---------------------------------------------------------------------------
|
||||
// | Copyright $_SWANBR_COPYRIGHT_$
|
||||
// +---------------------------------------------------------------------------
|
||||
// | Version $_SWANBR_VERSION_$
|
||||
// +---------------------------------------------------------------------------
|
||||
// | Licensed ( $_SWANBR_LICENSED_URL_$ )
|
||||
// +---------------------------------------------------------------------------
|
||||
// | $_SWANBR_WEB_DOMAIN_$
|
||||
// +---------------------------------------------------------------------------
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
use \Psr\Log\NullLogger;
|
||||
use \Psr\Log\LogLevel;
|
||||
|
||||
/**
|
||||
+------------------------------------------------------------------------------
|
||||
* Kafka protocol since Kafka v0.8
|
||||
+------------------------------------------------------------------------------
|
||||
*
|
||||
* @package
|
||||
* @version $_SWANBR_VERSION_$
|
||||
* @copyright Copyleft
|
||||
* @author $_SWANBR_AUTHOR_$
|
||||
+------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
trait LoggerTrait
|
||||
{
|
||||
/**
|
||||
* System is unusable.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function emergency($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::EMERGENCY, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action must be taken immediately.
|
||||
*
|
||||
* Example: Entire website down, database unavailable, etc. This should
|
||||
* trigger the SMS alerts and wake you up.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function alert($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::ALERT, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Critical conditions.
|
||||
*
|
||||
* Example: Application component unavailable, unexpected exception.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function critical($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::CRITICAL, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runtime errors that do not require immediate action but should typically
|
||||
* be logged and monitored.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function error($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::ERROR, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exceptional occurrences that are not errors.
|
||||
*
|
||||
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
||||
* that are not necessarily wrong.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function warning($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::WARNING, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal but significant events.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function notice($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::NOTICE, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interesting events.
|
||||
*
|
||||
* Example: User logs in, SQL logs.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function info($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::INFO, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detailed debug information.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function debug($message, array $context = array())
|
||||
{
|
||||
$this->log(LogLevel::DEBUG, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs with an arbitrary level.
|
||||
*
|
||||
* @param mixed $level
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
if ($this->logger == null) {
|
||||
$this->logger = new NullLogger();
|
||||
}
|
||||
$this->logger->log($level, $message, $context);
|
||||
}
|
||||
}
|
||||
+1
-12
@@ -1,16 +1,5 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
||||
// +---------------------------------------------------------------------------
|
||||
// | SWAN [ $_SWANBR_SLOGAN_$ ]
|
||||
// +---------------------------------------------------------------------------
|
||||
// | Copyright $_SWANBR_COPYRIGHT_$
|
||||
// +---------------------------------------------------------------------------
|
||||
// | Version $_SWANBR_VERSION_$
|
||||
// +---------------------------------------------------------------------------
|
||||
// | Licensed ( $_SWANBR_LICENSED_URL_$ )
|
||||
// +---------------------------------------------------------------------------
|
||||
// | $_SWANBR_WEB_DOMAIN_$
|
||||
// +---------------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kafka;
|
||||
|
||||
@@ -15,7 +15,7 @@ class Struct
|
||||
public string $topic;
|
||||
|
||||
public string $value;
|
||||
public string $part;
|
||||
public int $part;
|
||||
|
||||
/**
|
||||
* Struct constructor.
|
||||
|
||||
Reference in New Issue
Block a user