コード例 #1
0
ファイル: KafkaHandler.php プロジェクト: paladox/mediawiki
 /**
  * Constructs the necessary support objects and returns a KafkaHandler
  * instance.
  *
  * @param string[] $kafkaServers
  * @param array $options
  * @param int $level The minimum logging level at which this handle will be triggered
  * @param bool $bubble Whether the messages that are handled can bubble the stack or not
  * @return KafkaHandler
  */
 public static function factory($kafkaServers, array $options = [], $level = Logger::DEBUG, $bubble = true)
 {
     $metadata = new MetaDataFromKafka($kafkaServers);
     $produce = new Produce($metadata);
     if (isset($options['sendTimeout'])) {
         $timeOut = $options['sendTimeout'];
         $produce->getClient()->setStreamOption('SendTimeoutSec', 0);
         $produce->getClient()->setStreamOption('SendTimeoutUSec', intval($timeOut * 1000000));
     }
     if (isset($options['recvTimeout'])) {
         $timeOut = $options['recvTimeout'];
         $produce->getClient()->setStreamOption('RecvTimeoutSec', 0);
         $produce->getClient()->setStreamOption('RecvTimeoutUSec', intval($timeOut * 1000000));
     }
     if (isset($options['logExceptions']) && is_string($options['logExceptions'])) {
         $options['logExceptions'] = LoggerFactory::getInstance($options['logExceptions']);
     }
     if (isset($options['requireAck'])) {
         $produce->setRequireAck($options['requireAck']);
     }
     return new self($produce, $options, $level, $bubble);
 }