remove github.com/coreos/etcd/mvcc/mvccpb

pull/60/head
QLeelulu 7 years ago
parent b1e06fadc6
commit fe16425072

@ -3,7 +3,6 @@ go:
- 1.9 - 1.9
install: install:
- go get -u github.com/coreos/etcd/clientv3 - go get -u github.com/coreos/etcd/clientv3
- go get github.com/coreos/etcd/mvcc/mvccpb
- go get github.com/rogpeppe/fastuuid - go get github.com/rogpeppe/fastuuid
- go get golang.org/x/net/context - go get golang.org/x/net/context
- go get gopkg.in/mgo.v2 - go get gopkg.in/mgo.v2

@ -6,7 +6,6 @@ import (
"strings" "strings"
client "github.com/coreos/etcd/clientv3" client "github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/mvcc/mvccpb"
"github.com/shunfei/cronsun/conf" "github.com/shunfei/cronsun/conf"
"github.com/shunfei/cronsun/log" "github.com/shunfei/cronsun/log"
@ -65,10 +64,10 @@ func WatchGroups() client.WatchChan {
return DefalutClient.Watch(conf.Config.Group, client.WithPrefix(), client.WithPrevKV()) return DefalutClient.Watch(conf.Config.Group, client.WithPrefix(), client.WithPrevKV())
} }
func GetGroupFromKv(kv *mvccpb.KeyValue) (g *Group, err error) { func GetGroupFromKv(key, value []byte) (g *Group, err error) {
g = new(Group) g = new(Group)
if err = json.Unmarshal(kv.Value, g); err != nil { if err = json.Unmarshal(value, g); err != nil {
err = fmt.Errorf("group[%s] umarshal err: %s", string(kv.Key), err.Error()) err = fmt.Errorf("group[%s] umarshal err: %s", string(key), err.Error())
} }
return return
} }

@ -16,7 +16,6 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
client "github.com/coreos/etcd/clientv3" client "github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/mvcc/mvccpb"
"github.com/shunfei/cronsun/conf" "github.com/shunfei/cronsun/conf"
"github.com/shunfei/cronsun/log" "github.com/shunfei/cronsun/log"
@ -371,10 +370,10 @@ func WatchJobs() client.WatchChan {
return DefalutClient.Watch(conf.Config.Cmd, client.WithPrefix()) return DefalutClient.Watch(conf.Config.Cmd, client.WithPrefix())
} }
func GetJobFromKv(kv *mvccpb.KeyValue) (job *Job, err error) { func GetJobFromKv(key, value []byte) (job *Job, err error) {
job = new(Job) job = new(Job)
if err = json.Unmarshal(kv.Value, job); err != nil { if err = json.Unmarshal(value, job); err != nil {
err = fmt.Errorf("job[%s] umarshal err: %s", string(kv.Key), err.Error()) err = fmt.Errorf("job[%s] umarshal err: %s", string(key), err.Error())
return return
} }

@ -364,7 +364,7 @@ func (n *Node) watchJobs() {
for _, ev := range wresp.Events { for _, ev := range wresp.Events {
switch { switch {
case ev.IsCreate(): case ev.IsCreate():
job, err := cronsun.GetJobFromKv(ev.Kv) job, err := cronsun.GetJobFromKv(ev.Kv.Key, ev.Kv.Value)
if err != nil { if err != nil {
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String()) log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
continue continue
@ -373,7 +373,7 @@ func (n *Node) watchJobs() {
job.Init(n.ID) job.Init(n.ID)
n.addJob(job, true) n.addJob(job, true)
case ev.IsModify(): case ev.IsModify():
job, err := cronsun.GetJobFromKv(ev.Kv) job, err := cronsun.GetJobFromKv(ev.Kv.Key, ev.Kv.Value)
if err != nil { if err != nil {
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String()) log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
continue continue
@ -396,7 +396,7 @@ func (n *Node) watchGroups() {
for _, ev := range wresp.Events { for _, ev := range wresp.Events {
switch { switch {
case ev.IsCreate(): case ev.IsCreate():
g, err := cronsun.GetGroupFromKv(ev.Kv) g, err := cronsun.GetGroupFromKv(ev.Kv.Key, ev.Kv.Value)
if err != nil { if err != nil {
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String()) log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
continue continue
@ -404,7 +404,7 @@ func (n *Node) watchGroups() {
n.addGroup(g) n.addGroup(g)
case ev.IsModify(): case ev.IsModify():
g, err := cronsun.GetGroupFromKv(ev.Kv) g, err := cronsun.GetGroupFromKv(ev.Kv.Key, ev.Kv.Value)
if err != nil { if err != nil {
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String()) log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
continue continue

Loading…
Cancel
Save