septech-laravel / kafka
Laravel 的 Rdkafka 连接器
v1.0.5
2020-11-18 04:39 UTC
Requires
- ext-rdkafka: *
- illuminate/support: ^v7.0.0
This package is auto-updated.
Last update: 2024-09-28 09:50:13 UTC
README
composer require septech-laravel/kafka
使用方法
环境变量
# The kafka brokers, seperate by command
KAFKA_BROKERS=10.0.0.2,127.0.0.1
KAFKA_SSL_CA_LOCATION=./ca.crt
# For SSL client
SECURITY_PROTOCOL=[ssl | plaintext]
KAFKA_SSL_CERTIFICATE_LOCATION=./user.crt
KAFKA_SSL_KEY_LOCATION=./user.key
KAFKA_SSL_KEY_PASSWORD=SOME_PASSWORD
通过注入
<?php use Septech\Kafka\Kafka; class MessageController { public function send(Kafka $kafka) { $message = json_encode(['message' => 'Hi, from kafka with love <3']); $kafka->produce("some.topic", $message); } }
通过外观
<?php use Septech\Kafka\Facades\Kafka; $message = json_encode(['message' => 'Hi, from kafka with love <3']); Kafka::produce("some.topic", $message);
看起来这个包缺少一些东西?
嗯,没有任何东西是第一次就绝对完美的。我只是为了我的目的创建了这个包。如果你想为这个包添加更多功能,那需要你的帮助。欢迎发送PR给我。