Documentation ¶
Index ¶
- Constants
- type Config
- type Monitor
- func (m *Monitor) Run() error
- func (m *Monitor) VerifyBillingLags() error
- func (m *Monitor) VerifyChannelsForInactivity() error
- func (m *Monitor) VerifySuspendedChannelsAndTryToTerminate() error
- func (m *Monitor) VerifySuspendedChannelsAndTryToUnsuspend() error
- func (m *Monitor) VerifyUnitsBasedChannels() error
Constants ¶
const ( // CRC16("github.com/privatix/dappctrl/agent/bill") = 0x6D62 ErrInput errors.Error = 0x6D62<<8 + iota )
Errors.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Interval uint64 // In milliseconds.
}
Config is a billing monitor configuration for agent.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor provides logic for checking channels for various cases, in which service(s) must be suspended/terminated/or unsuspended (continued). All conditions are checked on the DB level, so it is safe to call monitors methods from separate goroutines.
func NewMonitor ¶
func NewMonitor(interval uint64, db *reform.DB, logger log.Logger, pr *proc.Processor) (*Monitor, error)
NewMonitor creates new instance of billing monitor. 'interval' specifies how often channels checks must be performed.
func (*Monitor) Run ¶
Run begins monitoring of channels. In case of error - doesn't restarts automatically.
func (*Monitor) VerifyBillingLags ¶
VerifyBillingLags checks all active channels for billing lags, and schedules suspending of those, who are suffering from billing lags.
func (*Monitor) VerifyChannelsForInactivity ¶
VerifyChannelsForInactivity scans all channels, that are not terminated, and terminates those of them, who are staying inactive too long.
func (*Monitor) VerifySuspendedChannelsAndTryToTerminate ¶
VerifySuspendedChannelsAndTryToTerminate scans all suspended channels, and terminates those of them, who are staying suspended too long.
func (*Monitor) VerifySuspendedChannelsAndTryToUnsuspend ¶
VerifySuspendedChannelsAndTryToUnsuspend scans all supsended channels, and checks if all conditions are met to unsuspend them. Is so - schedules task for appropriate channel unsuspending.
func (*Monitor) VerifyUnitsBasedChannels ¶
VerifyUnitsBasedChannels checks all active units based channels for not using more units, than provided by quota and not exceeding over total deposit.