watcher.go 496 B

12345678910111213141516
  1. package raft
  2. // WatchHandler defines the function signature for watching key changes
  3. type WatchHandler func(key, value string, eventType KVCommandType)
  4. // Watcher interface for specialized handling
  5. type Watcher interface {
  6. OnWait(key, value string, eventType KVCommandType)
  7. }
  8. // WatcherWrapper adapts a Watcher interface to a WatchHandler function
  9. func WatcherWrapper(w Watcher) WatchHandler {
  10. return func(key, value string, eventType KVCommandType) {
  11. w.OnWait(key, value, eventType)
  12. }
  13. }