seomoz/askari — pull request #67 by phs (2013-10-22 06:49:48+00:00)
Title: Phs/coprocessor dsl

Here's `RegionObserver::DSL`, `::Application` and `::Runner`.

The `DSL` offers a sinatra-esque way to build up a set of coprocessor callbacks, which accumulate in a hidden, associated `Application` instance. This `Application` will then be handed to a `Runner`, which interfaces with our java `RegionObserver` implementation to drive event dispatch.

Each kind of event (e.g. `:post_put`) registers a dispatcher responsible for invoking handlers and folding results.

We choose to imitate HBase's own dispatch rules (across coprocessors), so that multiple (say) post_put hooks function identically whether they share the same askari coprocessor instance or not. These can be inspected in HBase source in `RegionCoprocessorHost`.

This dispatch process is nearly identical for all events, but three key facts vary between them:
* Some events are expected to return a value, others do not.
* The results of some handlers are expected to be fed into the arguments of successive handlers, others not. The identity (index) of this "pivot" argument of course varies between events.
* Some events choose to respect the `#complete` method on their contexts by terminating dispatch before later handlers get invoked. Other events ignore `#complete.`

`Relation` has been extended to surface `#key_values`, `#cells`, `#add_value`, `#add_column`, and `#add_family`. `ExecutionContext#relation` in turn exposes `Relation`s.

Also drop the lock/unlock coprocessor events, they're deprecated.