-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinterface.go
128 lines (111 loc) · 3.77 KB
/
interface.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package core
import (
"time"
)
// AppStatusHandler interface will handle different implementations of monitoring tools, such as term-ui or status metrics
type AppStatusHandler interface {
IsInterfaceNil() bool
Increment(key string)
AddUint64(key string, val uint64)
Decrement(key string)
SetInt64Value(key string, value int64)
SetUInt64Value(key string, value uint64)
SetStringValue(key string, value string)
Close()
}
// ConnectedAddressesHandler interface will be used for passing the network component to AppStatusPolling
type ConnectedAddressesHandler interface {
ConnectedAddresses() []string
}
// PubkeyConverter can convert public key bytes to/from a human readable form
type PubkeyConverter interface {
Len() int
Decode(humanReadable string) ([]byte, error)
Encode(pkBytes []byte) string
IsInterfaceNil() bool
}
// TimersScheduler exposes functionality for scheduling multiple timers
type TimersScheduler interface {
Add(callback func(alarmID string), duration time.Duration, alarmID string)
Cancel(alarmID string)
Close()
Reset(alarmID string)
IsInterfaceNil() bool
}
// NodeTypeProviderHandler defines the actions needed for a component that can handle the node type
type NodeTypeProviderHandler interface {
SetType(nodeType NodeType)
GetType() NodeType
IsInterfaceNil() bool
}
// WatchdogTimer is used to set alarms for different components
type WatchdogTimer interface {
Set(callback func(alarmID string), duration time.Duration, alarmID string)
SetDefault(duration time.Duration, alarmID string)
Stop(alarmID string)
Reset(alarmID string)
IsInterfaceNil() bool
}
// Throttler can monitor the number of the currently running go routines
type Throttler interface {
CanProcess() bool
StartProcessing()
EndProcessing()
IsInterfaceNil() bool
}
// KeyValueHolder is used to hold a key and an associated value
type KeyValueHolder interface {
Key() []byte
Value() []byte
ValueWithoutSuffix(suffix []byte) ([]byte, error)
}
// EpochSubscriberHandler defines the behavior of a component that can be notified if a new epoch was confirmed
type EpochSubscriberHandler interface {
EpochConfirmed(epoch uint32, timestamp uint64)
IsInterfaceNil() bool
}
// Accumulator defines the interface able to accumulate data and periodically evict them
type Accumulator interface {
AddData(data interface{})
OutputChannel() <-chan []interface{}
Close() error
IsInterfaceNil() bool
}
// GasScheduleSubscribeHandler defines the behavior of a component that can be notified if a the gas schedule was changed
type GasScheduleSubscribeHandler interface {
GasScheduleChange(gasSchedule map[string]map[string]uint64)
IsInterfaceNil() bool
}
// EpochNotifier can notify upon an epoch change and provide the current epoch
type EpochNotifier interface {
RegisterNotifyHandler(handler EpochSubscriberHandler)
IsInterfaceNil() bool
}
// GasScheduleNotifier can notify upon a gas schedule change
type GasScheduleNotifier interface {
RegisterNotifyHandler(handler GasScheduleSubscribeHandler)
LatestGasSchedule() map[string]map[string]uint64
UnRegisterAll()
IsInterfaceNil() bool
}
// Queue is an interface for queue implementations that evict the first element when the queue is full
type Queue interface {
Add(hash []byte) []byte
}
// SafeCloser represents a subcomponent used for signaling a closing event. Its Close method is considered to be
// concurrent safe
type SafeCloser interface {
Close()
ChanClose() <-chan struct{}
IsInterfaceNil() bool
}
// Logger defines the behavior of a data logger component
type Logger interface {
Trace(message string, args ...interface{})
Debug(message string, args ...interface{})
Info(message string, args ...interface{})
Warn(message string, args ...interface{})
Error(message string, args ...interface{})
LogIfError(err error, args ...interface{})
IsInterfaceNil() bool
}