mirror of https://github.com/shunfei/cronsun
remove github.com/coreos/etcd/mvcc/mvccpb
parent
b1e06fadc6
commit
fe16425072
|
@ -3,7 +3,6 @@ go:
|
|||
- 1.9
|
||||
install:
|
||||
- go get -u github.com/coreos/etcd/clientv3
|
||||
- go get github.com/coreos/etcd/mvcc/mvccpb
|
||||
- go get github.com/rogpeppe/fastuuid
|
||||
- go get golang.org/x/net/context
|
||||
- go get gopkg.in/mgo.v2
|
||||
|
|
7
group.go
7
group.go
|
@ -6,7 +6,6 @@ import (
|
|||
"strings"
|
||||
|
||||
client "github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/mvcc/mvccpb"
|
||||
|
||||
"github.com/shunfei/cronsun/conf"
|
||||
"github.com/shunfei/cronsun/log"
|
||||
|
@ -65,10 +64,10 @@ func WatchGroups() client.WatchChan {
|
|||
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)
|
||||
if err = json.Unmarshal(kv.Value, g); err != nil {
|
||||
err = fmt.Errorf("group[%s] umarshal err: %s", string(kv.Key), err.Error())
|
||||
if err = json.Unmarshal(value, g); err != nil {
|
||||
err = fmt.Errorf("group[%s] umarshal err: %s", string(key), err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
7
job.go
7
job.go
|
@ -16,7 +16,6 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
|
||||
client "github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/mvcc/mvccpb"
|
||||
|
||||
"github.com/shunfei/cronsun/conf"
|
||||
"github.com/shunfei/cronsun/log"
|
||||
|
@ -371,10 +370,10 @@ func WatchJobs() client.WatchChan {
|
|||
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)
|
||||
if err = json.Unmarshal(kv.Value, job); err != nil {
|
||||
err = fmt.Errorf("job[%s] umarshal err: %s", string(kv.Key), err.Error())
|
||||
if err = json.Unmarshal(value, job); err != nil {
|
||||
err = fmt.Errorf("job[%s] umarshal err: %s", string(key), err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ func (n *Node) watchJobs() {
|
|||
for _, ev := range wresp.Events {
|
||||
switch {
|
||||
case ev.IsCreate():
|
||||
job, err := cronsun.GetJobFromKv(ev.Kv)
|
||||
job, err := cronsun.GetJobFromKv(ev.Kv.Key, ev.Kv.Value)
|
||||
if err != nil {
|
||||
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
|
||||
continue
|
||||
|
@ -373,7 +373,7 @@ func (n *Node) watchJobs() {
|
|||
job.Init(n.ID)
|
||||
n.addJob(job, true)
|
||||
case ev.IsModify():
|
||||
job, err := cronsun.GetJobFromKv(ev.Kv)
|
||||
job, err := cronsun.GetJobFromKv(ev.Kv.Key, ev.Kv.Value)
|
||||
if err != nil {
|
||||
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
|
||||
continue
|
||||
|
@ -396,7 +396,7 @@ func (n *Node) watchGroups() {
|
|||
for _, ev := range wresp.Events {
|
||||
switch {
|
||||
case ev.IsCreate():
|
||||
g, err := cronsun.GetGroupFromKv(ev.Kv)
|
||||
g, err := cronsun.GetGroupFromKv(ev.Kv.Key, ev.Kv.Value)
|
||||
if err != nil {
|
||||
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
|
||||
continue
|
||||
|
@ -404,7 +404,7 @@ func (n *Node) watchGroups() {
|
|||
|
||||
n.addGroup(g)
|
||||
case ev.IsModify():
|
||||
g, err := cronsun.GetGroupFromKv(ev.Kv)
|
||||
g, err := cronsun.GetGroupFromKv(ev.Kv.Key, ev.Kv.Value)
|
||||
if err != nil {
|
||||
log.Warnf("err: %s, kv: %s", err.Error(), ev.Kv.String())
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue