From 15d85cf20dc26d981d45c7df5fb39b85d8350c5d Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Thu, 28 Jan 2016 16:23:22 -0800 Subject: [PATCH] KafkaHandler: allow customizing timeouts Bug: T125084 Change-Id: I8f01fa61d916aeaa831a84e12b6fae08d04ca046 --- includes/debug/logger/monolog/KafkaHandler.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/debug/logger/monolog/KafkaHandler.php b/includes/debug/logger/monolog/KafkaHandler.php index 4e8e65bd6f..24659186f6 100644 --- a/includes/debug/logger/monolog/KafkaHandler.php +++ b/includes/debug/logger/monolog/KafkaHandler.php @@ -99,9 +99,25 @@ class KafkaHandler extends AbstractProcessingHandler { ) { $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'] ); } + return new self( $produce, $options, $level, $bubble ); } -- 2.20.1