-
Notifications
You must be signed in to change notification settings - Fork 0
/
contracts.go
55 lines (41 loc) · 1.08 KB
/
contracts.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
package percounter
const GCounterNetworkMessage = "g-counter.network.message"
const PeerOhaiNetworkMessage = "peer.ohai.network.message"
const PeerHelloNetworkMessage = "peer.hello.network.message"
const MyIPKey = "my_ip"
const MyTcpPortKey = "my_tcp_port"
type GCounterStateSource interface {
GetState() GCounterState
}
type GCounterStateSink interface {
SetState(s GCounterState)
}
type QueryableCounter interface {
Incrementable
ValueSource
}
type Persistent interface {
PersistSync()
}
type ValueSource interface {
Value() int64
}
type CountEvent struct {
Name string
Count int64
}
type ClusterObserver interface {
AfterMessageSent(peer string, msg []byte)
AfterMessageReceived(peer string, msg []byte)
}
type CounterObserver interface {
OnNewCount(ev CountEvent)
}
type Incrementable interface {
Increment()
}
type noOpGcounterState struct{}
func (n *noOpGcounterState) GetState() GCounterState { return NewGcounterState() }
func (n *noOpGcounterState) SetState(s GCounterState) {}
type noOpCounterObserver struct{}
func (n *noOpCounterObserver) OnNewCount(CountEvent) {}