storage: move watcher interface into watcher.go
parent
de99c9ed58
commit
f71bcfa8ce
|
@ -76,22 +76,6 @@ type KV interface {
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watcher watches on the KV. It will be notified if there is an event
|
|
||||||
// happened on the watched key or prefix.
|
|
||||||
type Watcher interface {
|
|
||||||
// Event returns a channel that receives observed event that matches the
|
|
||||||
// context of watcher. When watch finishes or is canceled or aborted, the
|
|
||||||
// channel is closed and returns empty event.
|
|
||||||
// Successive calls to Event return the same value.
|
|
||||||
Event() <-chan storagepb.Event
|
|
||||||
|
|
||||||
// Err returns a non-nil error value after Event is closed. Err returns
|
|
||||||
// Compacted if the history was compacted, Canceled if watch is canceled,
|
|
||||||
// or EOF if watch reaches the end revision. No other values for Err are defined.
|
|
||||||
// After Event is closed, successive calls to Err return the same value.
|
|
||||||
Err() error
|
|
||||||
}
|
|
||||||
|
|
||||||
// WatchableKV is a KV that can be watched.
|
// WatchableKV is a KV that can be watched.
|
||||||
type WatchableKV interface {
|
type WatchableKV interface {
|
||||||
KV
|
KV
|
||||||
|
|
|
@ -20,6 +20,22 @@ import (
|
||||||
"github.com/coreos/etcd/storage/storagepb"
|
"github.com/coreos/etcd/storage/storagepb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Watcher watches on the KV. It will be notified if there is an event
|
||||||
|
// happened on the watched key or prefix.
|
||||||
|
type Watcher interface {
|
||||||
|
// Event returns a channel that receives observed event that matches the
|
||||||
|
// context of watcher. When watch finishes or is canceled or aborted, the
|
||||||
|
// channel is closed and returns empty event.
|
||||||
|
// Successive calls to Event return the same value.
|
||||||
|
Event() <-chan storagepb.Event
|
||||||
|
|
||||||
|
// Err returns a non-nil error value after Event is closed. Err returns
|
||||||
|
// Compacted if the history was compacted, Canceled if watch is canceled,
|
||||||
|
// or EOF if watch reaches the end revision. No other values for Err are defined.
|
||||||
|
// After Event is closed, successive calls to Err return the same value.
|
||||||
|
Err() error
|
||||||
|
}
|
||||||
|
|
||||||
type watcher struct {
|
type watcher struct {
|
||||||
key []byte
|
key []byte
|
||||||
prefix bool
|
prefix bool
|
||||||
|
|
Loading…
Reference in New Issue