func WatchAndUpdateBool(
	store kv.Store,
	key string,
	property *bool,
	lock sync.Locker,
	defaultValue bool,
	opts Options,
) (kv.ValueWatch, error) {
	if opts == nil {
		opts = NewOptions()
	}
	updateFn := lockedUpdate(func(i interface{}) { *property = i.(bool) }, lock)
	return watchAndUpdate(
		store, key, getBool, updateFn, opts.ValidateFn(), defaultValue, opts.Logger(),
	)
}
WatchAndUpdateBool sets up a watch with validation for a bool property. Any
malformed or invalid updates are not applied. The default value is applied
when the key does not exist in KV. The watch on the value is returned.
package util
import (
	"sync"
	"time"
	"github.com/m3db/m3cluster/kv"
)
func lockedUpdate(fn updateFn, lock sync.Locker) updateFn {
	return func(i interface{}) {
		if lock != nil {
			lock.Lock()
		}
		fn(i)
		if lock != nil {
			lock.Unlock()
		}
	}
}