Dynamic query rule support for vttablet

A few changes in this patch:

1. QueryRuleSources top level framework to manage dynamic query rule sources
    - Pluggable machanism for new dynamic query rule implementations
    - Complete decouple of query rule management and query service
2. File based and Zookeeper based dynamic custom rule support
3. Unit and site tests for dynamic query rule machanisms
I think since I compare if the file has changed or not, it won't clear
vttablet's internal cache. Yet Inotify is indeed a good way to improve this

2014-12-22 16:58 GMT-08:00 sougou <notifications@github.com>:
>
> In go/vt/tabletserver/customrule/filecustomrule/filecustomrule.go
> <https://github.com/youtube/vitess/pull/265#discussion-diff-22199750>:
>
> > +	rulePath string
> > +)
> > +
> > +// FileCustomRule is an implementation of CustomRuleManager based on
> > +// polling on a file which contains custom query rule definitions
> > +type FileCustomRule struct {
> > +	mu                      sync.Mutex
> > +	path                    string                   // Path to the file containing custom query rules
> > +	pollingInterval         time.Duration            // Interval in seconds at which FileCustomRule polls the file
> > +	currentRuleSet          *tabletserver.QueryRules // Caches latest successfully retrived QueryRules from polling
> > +	currentRuleSetTimestamp int64                    // Unix timestamp of last successful polling of QueryRules
> > +	finish                  chan int                 // Used by Close to signal the polling go routine to exit
> > +}
> > +
> > +// The minimum interval in seconds to poll the custom rule file
> > +const MinFilePollingSeconds time.Duration = 1
>
> Polling should be avoided. Either use inotify or don't poll at all. They
> can always restart vttablet in the worst case.
> Go has a low level API for inotify, which may be fun to play with.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/youtube/vitess/pull/265/files#r22199750>.
>