Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/280158
Change subject: [WIP] Kafka backend ...................................................................... [WIP] Kafka backend Change-Id: I869a9669ec1ce0550300bc0a4350423e09ce154b --- M README.md A src/PHPQueue/Backend/Kafka.php 2 files changed, 71 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/php-queue refs/changes/58/280158/1 diff --git a/README.md b/README.md index 72a73c8..dee6fea 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,11 @@ You can also include our core library files into your application and do some powerful heavy lifting. Several backend drivers are bundled: + * Kafka * Memcache * Redis * MongoDB + * STOMP * CSV These can be used as the primary job queue server, or for abstract FIFO or key-value data access. diff --git a/src/PHPQueue/Backend/Kafka.php b/src/PHPQueue/Backend/Kafka.php new file mode 100644 index 0000000..e9c41ce --- /dev/null +++ b/src/PHPQueue/Backend/Kafka.php @@ -0,0 +1,69 @@ +<?php +namespace PHPQueue\Backend; + +use PHPQueue\Exception\BackendException; +use PHPQueue\Interfaces\KeyValueStore; + +/** + * TODO: Support offset commit trickery. + */ +class Kafka + extends Base + implements FifoQueueStore +{ + public $servers; + public $is_persistent = false; + public $use_compression = false; + public $expiry = 0; + + protected $producerConnection; + protected $consumerConnection; + + public function __construct($options=array()) + { + parent::__construct(); + if (!empty($options['servers']) && is_array($options['servers'])) { + $this->servers = $options['servers']; + } + } + + public function connect() + { + if (empty($this->servers)) { + throw new BackendException("No servers specified"); + } + // FIXME: inheritance fail. This backend lazy-connects, see the next + // two functions. + } + + protected function getProducerConnection() { + if (!$this->producerConnection) { + $this->producerConnection = new \Kafka( + $this->servers, + array( + Kafka::CONFIRM_DELIVERY, + // XXX + ) + ); + } + return $this->producerConnection; + } + + protected function getConsumerConnection() { + if (!$this->consumerConnection) { + $this->consumerConnection = new \Kafka( + $this->servers, + array( + // XXX + ) + ); + } + return $this->consumerConnection; + } + + // TODO: push, pop + public function push($data) + { + $this->getProducerConnection()-> + } +} -- To view, visit https://gerrit.wikimedia.org/r/280158 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I869a9669ec1ce0550300bc0a4350423e09ce154b Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/php-queue Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits