-
Notifications
You must be signed in to change notification settings - Fork 51
Producer timeouts #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
produce and produceBatch Thee values are currently ignored; using them is coming next ;)
Clean up the topic config, not the topic obj itself (which hasn't been initialized yet)
Thanks for the PR... I'll go ahead and merge it in already. If you find the time, would you mind awfully looking into the refactored code base (https://github.com/EVODelavega/phpkafka/tree/feature/topic-objects/kafka_clean) and see how we can fit this in there? I'd be tempted to store the timeout value on the object itself, and allow changing it through a setter ( |
Producer timeout arguments
If I find the time I'll take a look...but don't count on it 😆 I'm not much of a C programmer; this was a quick fix I needed. I've since decided to go with a pure-php library for now (better timeout control, error handling, debuggability etc) until the rewrite is done & i can re-evaluate. It's worth noting that librdkafka has a bunch of other tunables; quite a few are probably worth exposing. |
@oris: I know librdkafka offers a lot more tweaking through its As for finding the time to look into all of this: I know the feeling 😆 |
@EVODelavega May I suggest that you implement a pass-through config interface that allows users of your PHP bindings to set any librdkafka configuration property? |
@edenhill That's the direction I want this extension to go in. What I want to end up with is a structure like this: Kafka(string brokers, array config) <-- this would actually be the Kafka::getTopic(string topic, int mode) <-- this holds the KafkaTopic::produceBatch(array messages, ...) & KafkaTopic::consumeBatch(...) These methods will return a queue (KafkaQueue), which would, in turn be configurable to some degree. I might split up these classes into The way shared resources ( $kafka = new Kafka($broker, $someConf);
$produceFoo = $kafka->getTopic('foo', Kafka::MODE_PRODUCER);
$secondProducer = $kafka->getTopic('foo', Kafka::MODE_PRODUCER);
$consumeFoo = $kafka->getTopic('foo', Kafka::MODE_CONSUMER); All three $queue = $produceFoo->produceBatch(
$hugeArray,
[
"queue.buffering.max.messages" => count($hugeArray),
"queue.buffering.max.ms" => count($hugeArray)*100,//100ms per msg
]
);//async produce call
$secondProducer->produce("simple msg", ["queue.buffering.max.ms" => 1000]); That might block PHP's RSHUTDOWN sequence, if the connection was set up to empty its buffers before closing... I hope all of this dribble makes sense. I'll have some spare time on my hands over the next couple of days, and I'm planning to work some more on this project this weekend. |
Since a single rd_kafka_t handle is bound to either PRODUCER of CONSUMER mode I'd suggest you to make the same interface in PHP, e.g.:
In about a month's time I'll be releasing the new consumer API that is somewhat (but not completely!) in line with the new official java consumer (http://kafka.apache.org/083/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html).
|
I'd strongly encourage this too; from the PHP side, the current extensions's 'mixed-mode' Kafka instance was a bit of a stumbling block for devs in my use-case. So far, we're preferring the explicit Consumer/Producer API separations in kafka-php -- you might want to mimic/emulate their API a bit (speaking selfishly, if you're feeling really adventurous, total compatibility with their API would be awesome for me :D) |
@orls Splitting up the consumer/producer modes is something that I'm definitely considering. Not doing so from the start was indeed a mistake. It would be nice to be able to write something line: public function foo(KafkaProducer $producer)
{
} and not having to write (as is the case now): public function foo(Kafka $conn)
{
if ($conn->getMode() !== Kafka::MODE_PRODUCER) {
throw new \InvalidArgumentException('Connection is not in producer mode');
}
} I'll certainly look into the kafka-php API for ideas, but 100% compatibility is probably something that's never going to happen. When I've finished the refactor (which is actually more like a redesign in drag anyway), I might look into writing a compatibility wrapper, though. @edenhill Is there a branch where I can get a preview of the new consumer API, because that API would map to PHP quite easily, especially in this case. Setting a default topic config on Anyway, thanks for the input, I've got my work cut out for me the next couple of days |
@EVODelavega It is currently work in progress, I'll probably push a functional but not final branch within a week or two. |
Support setting timeouts to all produce variants.
Also fixes a bug with an uninitialised obj in the CONFIRM_EXTENDED support