-
Notifications
You must be signed in to change notification settings - Fork 199
/
interface.go
87 lines (75 loc) · 2.59 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
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
}
// 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)
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
}