aerogram / adapter-kafka
There is no license information available for the latest version (0.3.0) of this package.
This package's canonical repository appears to be gone and the package has been frozen as a result.
0.3.0
2017-06-20 10:33 UTC
Requires
- ext-rdkafka: ^3.0
- aerogram/adapter: ~0.1
- aerogram/middleware: ~0.1
- psr/simple-cache: ^1.0
README
Installation
You must install a bunch of things before installing this component:
-
A Kafka server, obviously (check Bitnami for a simple install).
-
librdkafka, the Kafka client library
-
rdkafka PHP extension. For example through PHPBrew:
$ phpbrew ext install rdkafka
The recommended way to install aerogram/adapter-kafka
is through Composer.
$ composer require aerogram/adapter-kafka
Usage
The following snippet instantiate a bus with a Kafka transport.
The Kafka stream is divided between 16 (0 to F) partitions based on the hash of the event hash.
<?php use Aerogram\EventBus\EventBus\SimpleBus; use Aerogram\EventBus\Kafka\KafkaTransport; use Aerogram\EventBus\Kafka\Middleware\KafkaPartitioner; $bus = new SimpleBus( new KafkaTransport, [ new KafkaPartitioner(function($event, $options) { $hash = md5($event); return hexdec($hash{0}); }) ] ); // The following event will be published in partition 15 $bus->publish('event.test', '{"name": "test", "payload": "This is a test..."}');