Skip to content

Commit 4e308e1

Browse files
committed
fix(watcher): use types instead of string
1 parent ce5f984 commit 4e308e1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

etcd/watch.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/postfinance/store"
99

1010
"github.com/pkg/errors"
11+
"go.etcd.io/etcd/api/v3/mvccpb"
1112
clientv3 "go.etcd.io/etcd/client/v3"
1213
)
1314

@@ -101,10 +102,10 @@ func (e *Backend) Watch(key string, w store.Watcher, ops ...store.WatchOption) e
101102
for _, ev := range wresp.Events {
102103
key := []byte(e.RelKey(string(ev.Kv.Key)))
103104

104-
switch ev.Type.String() {
105-
case "PUT":
105+
switch ev.Type {
106+
case mvccpb.PUT:
106107
_ = handleError(w.OnPut(key, ev.Kv.Value))
107-
case "DELETE":
108+
case mvccpb.DELETE:
108109
_ = handleError(w.OnDelete(key, ev.Kv.Value))
109110
default:
110111
_ = handleError(fmt.Errorf("watch received an unknown event type: %s", ev.Type.String()))

0 commit comments

Comments
 (0)