doujiang24 / lua-resty-kafka

Lua kafka client driver for the Openresty based on the cosocket API
BSD 3-Clause "New" or "Revised" License
802 stars 275 forks source link

use semaphore:wait() if max_buffering is full #154

Closed lzle closed 1 year ago

lzle commented 1 year ago

When the producer.add function is executed, if max_buffering is full, you can use semaphore to wait instead of returning an "buffer overflow" directly. When the producer.add function is executed, continue to add to max_buffering

doujiang24 commented 1 year ago

@lzle Thanks for your contribution! we'd better add an option to enable it, and disable it by default, to keep backward compability, since the old behaviour could be used in log phase, there is not yield support, but semaphore need yield, can not be used in log phase safely.

lzle commented 1 year ago

@doujiang24 ok, thanks for the suggestion, I'll use option to keep backward compability.

lzle commented 1 year ago

@doujiang24 I adopted your suggestion and added the wait option to the code, please review it and give new suggestions

lzle commented 1 year ago

@doujiang24 The code has been modified, please give your valuable comments again, thank you!

lzle commented 1 year ago

@doujiang24 pease review again.😄

lzle commented 1 year ago

oh, we need some tests to cover this new behaviour.

great thanks!!

lzle commented 1 year ago

@doujiang24 I have added some test cases

doujiang24 commented 1 year ago

@lzle Thanks!