1.9.3 seems like it should actually still be using the
rb_thread_blocking_region() call, as ...call_without_gvl() isn't defined
in any header (although it is available).
Consuming that implicit declaration was causing crashes.
it's not safe to simply pluck strings off the heap unless we were also
going to maintain a reference to them. sidestep this problem by
strdup'ing the topic and brokers strings
this allows threaded code on modern (>=2.0) rubies working. Also,
switch to the single-message form of the rd_kafka call -- the callback
form isn't safe to run without the GVL held, as it enters the ruby
interpreter in rb_yield().
[1] pry(main)> d = Hermann::Discovery::Zookeeper.new('zk0.REDACTED.com:2181')
=> #<Hermann::Discovery::Zookeeper:0x57186526
@impl=
#<Hermann::Discovery::Zookeeper::CuratorImpl:0x391d1e33
@curator=
#<Java::OrgApacheCuratorFrameworkImps::CuratorFrameworkImpl:0x5287ba5f>>,
@zookeepers="zk0.REDACTED.com:2181">
[2] pry(main)> d.get_brokers
log4j:WARN No appenders could be found for logger (org.apache.curator.framework.imps.CuratorFrameworkImpl).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
=> ["kafka0.REDACTED.com:6667",
"kafka1.REDACTED.com:6667"]
[3] pry(main)>
[1] pry(main)> d = Hermann::Discovery::Zookeeper.new('zk0.REDACTED.com:2181')
=> #<Hermann::Discovery::Zookeeper:0x7b6141f0
@impl=
#<Hermann::Discovery::Zookeeper::ZkGemImpl:0x4fb64a52
@zookeepers="zk0.REDACTED.com:2181">,
@zookeepers="zk0.REDACTED.com:2181">
[2] pry(main)> d.get_brokers
log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
=> ["kafka0.REDACTED.com:6667",
"kafka1.REDACTED.com:6667"]
[3] pry(main)>
This change makes the loading of the 'zk' gem optional and implicit, as well as
the reliance on Curator being available in the JRuby runtime's classpath.
If neither Zookeeper client implementation are available, an exception will be
raised when attmepting to use Zookeeper-based discovery
Fixes#75