-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelegate.go
73 lines (58 loc) · 1.42 KB
/
delegate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2016 F. Alan Jones. All rights reserved.
// Use of this source code is governed by a Mozilla
// license that can be found in the LICENSE file.
package ketch
import (
"github.com/Sirupsen/logrus"
"github.com/watercraft/ketch/msg"
)
func (k *Ketch) NodeMeta(limit int) []byte {
k.Lock()
defer k.Unlock()
k.log.WithFields(Locate(logrus.Fields{
"limit": limit,
"id": k.runtime.ID,
})).Info("NodeMeta")
return k.runtime.ID.Bytes()
}
func (k *Ketch) NotifyMsg(buf []byte) {
// Decode message
msg, err := msg.FromBytes(buf)
if err != nil {
k.log.WithFields(Locate(logrus.Fields{
"err": err,
"size": len(buf),
"buf": buf,
})).Error("Failed to decode incoming message")
return
}
select {
case k.incomingMsgCh <- msg:
default:
k.log.WithFields(Locate(logrus.Fields{
"size": len(buf),
"msg": msg,
})).Error("Incomming message channel full, discarding message")
}
return
}
func (k *Ketch) GetBroadcasts(overhead, limit int) [][]byte {
k.log.WithFields(Locate(logrus.Fields{
"overhead": overhead,
"limit": limit,
})).Debug("GetBroadcasts")
return [][]byte{}
}
func (k *Ketch) LocalState(join bool) []byte {
k.log.WithFields(Locate(logrus.Fields{
"join": join,
})).Debug("LocalState")
return []byte{}
}
func (k *Ketch) MergeRemoteState(buf []byte, join bool) {
k.log.WithFields(Locate(logrus.Fields{
"buf": buf,
"join": join,
})).Info("MergeRemoteState")
return
}