-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
WIP: JRuby support #106
WIP: JRuby support #106
Conversation
Free ptr objects in ensure blocks and add workaround for lack of read(:pointer), read_string_to_null and read_int64 ffi methods in JRuby
I don't think the spec matches the description here. It should be
This did not fail in my local. I will try a few sample runs and see if it'll be consistent. |
Wow @Adithya-copart - I'm the creator of Karafka and yes, once we switch Karafka to librdkafka, JRuby and Truffle Ruby support will be restored. Your changes are a huge step towards that! FYI Waterdrop is already ported to librdkafka! |
Thanks for your contribution! jRuby support wasn't initially a goal of this project. When running on the JVM I don't think it makes sense to use librdkafka. The Kafka Java client library seems like a more natural and probably more performant fit. In an ideal world I think there should be another gem that's a great wrapper around the latest version of the Java client and one could swap them in or out. But that's a lot of work so I think making the FFI setup compatible with jRuby is probably the best way forward. I'll take a look at the code shortly. |
But you have to build up the whole ecosystem yourself. That is you will have to use the native Java stuff and rediscover them in the Ruby context. With those changes, you will soon get Karafka running with librdkafka underneath that could run with jruby and truffle for free. |
I agree that this is the most pragmatic way forward. But viewed from a purely technical standpoint a Java wrapper would be the best the choice in my opinion. |
You both made good points. The costs associated with using native Java client in JRuby are not justifiable for us at the moment. It makes sense to add the dependencies for @mensfeld I did not look deep into Is the The costs associated with spawning a separate JVM per consumer group may not be scalable for JRuby and might be better to run multiple threads in the JVM. It might add the possibility of running multiple consumers in different consumer groups within the same process where using a single consumer to subscribe to multiple topics is not feasible. I'm confident that this approach may not fit in libraries like |
@Adithya-copart I don't want to go offtop here about Karafka so I opened an issue with your question: karafka/karafka#570 |
This pull is also blocked on #98 by the way, if anybody has any fresh thoughts on that I'd love to hear them. |
Modify error_spec and skip the spec using fork in JRuby. Use RbConfig to check for MacOS.
@thijsc In my local, these error messages always follow a closed socket warning in the Kafka logs. I had one of the forked process SegFault while calling the finalizer on a AutoPointer object. |
…for JRuby for reason still unknown
This reverts commit 38ea6d6.
The tests are green in all 4 but travis encountered a SegFault in MRI builds after final GC.
|
72bc7a0
to
c739dd5
Compare
When converting a Rdkafka::TopicPartitionList to a native type, Rdkafka was depending on AutoPointer to eventually free them. There are a couple cases where a Client handle returns a pointer to the application that the application is then required to free, which could be leading to test instability. This takes a pass at ensuring all uses of native TopicPartitionList instances (even those return) are deterministically freed.
Thanks for the library.
I came across karafka/karafka#433 (comment) and assumed that the maintainers would be willing to support JRuby as
rdkafka-ruby
appears to be the future backend for gems likekarafka, racecar etc.
The changes in this PR include:
read_int64, read(:pointer), read_string_to_null
.Pointer#autorelease=
.producer_spec
to avoid intermittent failures.The lack of these methods probably could be fixed by jruby/jruby#5947.
Pointer#autorelease=
is not available which was introduced in #73. I tried to manually free them within theensure
blocks.I'm don't think this is necessary as the
*_ptrptr
and*_ptr
appear to be freed by the time ensure blocks are being run.