Merge pull request #102 from basho/rz-use-rt-config

Use `rt_config:get_os_env`
Use mochiglobal to cache + get coverage plans

Creating a coverage plan consumes a lot of CPU and creates potentially
large lists (garbage) on the process potentially leading to GC.  This
gets worse as the ring size increases.

Currently Yokozuna creates a coverage plan _per_ request.  I.e. every
search request must first pay the expensive cost of calculating a plan
before running the search.  But it doesn't have to be this way.  The
plans could be periodically calculated in an out-of-band process and
cached in a good read-heavy solution like mochiglobal.

There is no reason to calc a plan per request.  The argument could be
made that this is the only way to avoid sending requests to downed
nodes but that is false.  Coverage relies on nodewatcher which uses
net-kernel tick which runs on a delay of ~15s.

The other argument could be ring change (join/remove a node).  In this
case the cached plan might be in disagreement with the ring.  The
divergence would last for a maximum upper bound of T where T is the
period of time before a new plan is written to the index.  This is
already a problem in Riak where the ring changes between the time a
coordinator fires of a request and the vnodes see it.  I'm just going
to punt and assume vnode forwarding should take care of this.  Even if
this isn't the case this scenario is made more rare by the fact that
the partition that has moved must be part of the plan.  This can also
be made even more rare by invalidating the cache on ring change events.

This patch makes the following changes:

* A new plan is generated for each index every 2 seconds.

* During a search request the cache is first checked.  The cache uses
  mochiglobal which generates BEAM code dynamically so that the cost
  of a fetch is that of a function call.

* If the cache doesn't have a plan stored for the index then a plan
  will be generated as part of the request.

* The `yz_cover` module is now a `gen_sever`.  It's responsibility is
  to periodically re-generate plans for each index and cache them.

NOTE: Another thing that might worry someone about this patch is that
using the same plan means not load-balancing well.  But this matters
less re Yokozuna for two reasons.

1. Yokozuna doesn't have vnodes, so balancing across vnodes doesn't
   matter.

2. Coverage currently seems to always select all nodes.  Once coverage
   gets better at optimizing for nodes then it would be wise to cache
   multiple plans and round-robin them.
I was told date ranges are not needed in copyright headers
Pull cover tick interval from app config

Allow the user to change the cover tick.  Default to 2s.
Merge pull request #103 from basho/rz-coverage-mochi-global

Use mochiglobal to cache + get coverage plans
Add protocol buffer query service at parity with Riak Search and corrosponding r_t
Add `enabled` flag to config

Allow Yokozuna to be enabled/disable based on the `enabled` config.
If set to `true` then Yokozuna will be started, `false` and it will
not.

* When disabled, the `yz_sup` process is still started but it will
  have no children.  Furthermore the webmachine resource will not be
  registered and the yokozuna service will not be marked up.

* I think you could enable Yokozuna on-the-fly, i.e. without
  restarting the VM, by changing the enabled flag to true and then
  running `application:stop` followed by `application:start`.
Expand test to include params and unicode, make pb service safer in the face of unforseen errors
Merge pull request #104 from basho/rz-enabled-flag

Add `enabled` flag to config
Fix list encoding to allow lists of strings, fix tests
Remove riakdoc extractor
Merge pull request #110 from basho/er-remove-riakdoc

Remove riakdoc extractor
Add Q & A doc

This will serve as a dumping ground for all sorts of documentation
until there is a need to group related questions into a top-level
topic.
Merge pull request #113 from basho/rz-qanda

Add Q & A doc
add instruction about enabling yokozuna to README.
Don't crash cover on insufficient_vnodes_available

* Change `calc_plan` to return error-tuple rather than match it and
  throw it.

* Check for error-tuple when generating cached coverage plans and
  store undefined.  That will prevent cover server from crashing.

* Check for error-tuple during search request and return proper error
  msg to user.
Merge pull request #114 from basho/kaz-update-readme

add instruction about enabling yokozuna to README.
Add multi-value field support

* Instead of concatenating multi-valued fields into one binary add a
  `{FieldName, FieldVal}` pair to the result for each value.

* Add a test for multi-valued fields.

* Log the stacktrace for an unknown error.
Merge branch 'er-pbsupport'

Conflicts:
	src/yz_app.erl

Had to move the PB register call into `maybe_setup`.
Enable yokozuna for all tests