twitter/zookeeper — pull request #14 by slyphon (2012-04-30 16:01:39+00:00)
Title: It's been so long, figured we should catch up. A year's worth of maintenance on twitter/zookeeper

For roughtly the past year I've been developing this codebase in my fork, and doing regular releases in support of the [ZK](https://github.com/slyphon/zk) gem. There are really too many changes to list here (it's been a year since the last pull request), from the CHANGELOG file here are some of the greatest hits:

v0.9.2 More efficient and simpler wrappers for GIL release

* After a code review by Andrew Wason (rectalogic), use a much simpler
technique for creating the arg structs and passing them to the
zkrb_gvl_* functions. No malloc(), no free(), no problem.

v0.9.1 see v0.8.4 notes, same patch

v0.9.0 RELEASE THE KRAK..er, GIL!!

* In >= 1.9.2 the ruby interpreter allows you to release the GIL when
calling into native code, sounds like a good idea.

This release makes use of that code by parsing the zookeeper.h header file
and extracting the method signatures of all relevant zoo_* functions, then
generating boilerplate that allows us to call those functions via the
rb_thread_blocking_region function.

1.8.7 compatibility is maintained by stubbing out that functionality if built
under 1.8.7.

* 1.8.7 is deprecated! I will continue to support 1.8.7 for the near future
but sometime soon, you're gonna have to upgrade.

v0.8.4 fix NameError, require 'forwardable'

* Really not sure why this didn't come up in tests

* issue here https://github.com/slyphon/zk/issues/22

v0.8.3 fix NonLocalJump exception in event delivery thread shutdown code

* hit a corner case where we're waiting for the zkc handle setup
and the user decides to shutdown, but before we've had a chance
to enter the delivery loop.

* Cleaned up some nasty code in ZookeeperConstants

* removed ZookeeperConstants#print_events and ZookeeperConstants#print_states

* changed EVENT_TYPE_NAMES and EVENT_STATE_NAMES in ZookeeperConstants
to use string values instead of symbols

v0.8.2 fix close after a fork()

* The dispatch thread will be dead in this situation, so we need to
check to see if it's already dead before waiting on it to exit.

v0.8.1 Java client fix, silence warnings

v0.8.0 Refactor C implementaion, EventMachine client

* separated CZookeeper and ZookeeperBase implementation

This solves issues with reopen not working properly, makes for a much
cleaner event delivery implementation. ZookeeperBase controls the lifecycle
of the event dispatch thread now, rather than it being tied to CZookeeper.

* added support for the 'sync' API call

* Refactored zookeeper_c.c and zookeeper_lib.c

More error checking in zookeeper_lib.c and restructure some things to make
logic easier to follow

Fix bug in method_get_next_event that made the shutdown case so complicated

* Massively simplified EMClient implementation

Rather than trying to hook the IO used by zookeeper_lib to notify zookeeper_c
about event availabiltiy directly into EventMachine, use the same event delivery
thread, but wrap the dispatch call in EM.schedule.

* Improve implementation of spin-lock-esque code that waits for the connection to be
established before returning.

This cut the test runtime down from 1m 20s to 2s.

* Java client refactoring, similar correctness changes

* Change ZookeeperException base class to StandardError instead of Exception

In addition, I've added a Gemfile, fixed chrooted connection behavior so that the C implementation matches the Java client, rake scripts for testing across 5 different ruby implementations (using rvm), and added lots more tests.

I'm a committer on this project, so I'm going to let this pull request sit for a while, and if I don't hear any objections, I'm going to accept and merge it.