|
@@ -50,6 +50,9 @@ type Op struct {
|
|
|
|
|
|
|
|
// progressNotify is for progress updates.
|
|
// progressNotify is for progress updates.
|
|
|
progressNotify bool
|
|
progressNotify bool
|
|
|
|
|
+ // filters for watchers
|
|
|
|
|
+ filterPut bool
|
|
|
|
|
+ filterDelete bool
|
|
|
|
|
|
|
|
// for put
|
|
// for put
|
|
|
val []byte
|
|
val []byte
|
|
@@ -111,6 +114,8 @@ func OpDelete(key string, opts ...OpOption) Op {
|
|
|
panic("unexpected serializable in delete")
|
|
panic("unexpected serializable in delete")
|
|
|
case ret.countOnly:
|
|
case ret.countOnly:
|
|
|
panic("unexpected countOnly in delete")
|
|
panic("unexpected countOnly in delete")
|
|
|
|
|
+ case ret.filterDelete, ret.filterPut:
|
|
|
|
|
+ panic("unexpected filter in delete")
|
|
|
}
|
|
}
|
|
|
return ret
|
|
return ret
|
|
|
}
|
|
}
|
|
@@ -131,6 +136,8 @@ func OpPut(key, val string, opts ...OpOption) Op {
|
|
|
panic("unexpected serializable in put")
|
|
panic("unexpected serializable in put")
|
|
|
case ret.countOnly:
|
|
case ret.countOnly:
|
|
|
panic("unexpected countOnly in put")
|
|
panic("unexpected countOnly in put")
|
|
|
|
|
+ case ret.filterDelete, ret.filterPut:
|
|
|
|
|
+ panic("unexpected filter in put")
|
|
|
}
|
|
}
|
|
|
return ret
|
|
return ret
|
|
|
}
|
|
}
|
|
@@ -274,6 +281,16 @@ func WithProgressNotify() OpOption {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// WithFilterPut discards PUT events from the watcher.
|
|
|
|
|
+func WithFilterPut() OpOption {
|
|
|
|
|
+ return func(op *Op) { op.filterPut = true }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// WithFilterDelete discards DELETE events from the watcher.
|
|
|
|
|
+func WithFilterDelete() OpOption {
|
|
|
|
|
+ return func(op *Op) { op.filterDelete = true }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted,
|
|
// WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted,
|
|
|
// nothing will be returned.
|
|
// nothing will be returned.
|
|
|
func WithPrevKV() OpOption {
|
|
func WithPrevKV() OpOption {
|