func keyWatch(params map[string]interface{}) (WatchFunc, error) {
	var key string
	if err := assignValue(params, "key", &key); err != nil {
		return nil, err
	}
	if key == "" {
		return nil, fmt.Errorf("Must specify a single key to watch")
	}
	fn := func(p *WatchPlan) (uint64, interface{}, error) {
		kv := p.client.KV()
		opts := consulapi.QueryOptions{WaitIndex: p.lastIndex}
		pair, meta, err := kv.Get(key, &opts)
		if err != nil {
			return 0, nil, err
		}
		if pair == nil {
			return meta.LastIndex, nil, err
		}
		return meta.LastIndex, pair, err
	}
	return fn, nil
}
keyWatch is used to return a key watching function
package watch
import (
	"fmt"
	consulapi "github.com/hashicorp/consul/api"
)
type watchFactory func(params map[string]interface{}) (WatchFunc, error)
var watchFuncFactory map[string]watchFactory
func init() {
	watchFuncFactory = map[string]watchFactory{
		"key":       keyWatch,
		"keyprefix": keyPrefixWatch,
		"services":  servicesWatch,
		"nodes":     nodesWatch,
		"service":   serviceWatch,
		"checks":    checksWatch,
		"event":     eventWatch,
	}
}