billing

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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.

func NewConfig

func NewConfig() *Config

NewConfig creates a new 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

func (m *Monitor) Run() error

Run begins monitoring of channels. In case of error - doesn't restarts automatically.

func (*Monitor) VerifyBillingLags

func (m *Monitor) VerifyBillingLags() error

VerifyBillingLags checks all active channels for billing lags, and schedules suspending of those, who are suffering from billing lags.

func (*Monitor) VerifyChannelsForInactivity

func (m *Monitor) VerifyChannelsForInactivity() error

VerifyChannelsForInactivity scans all channels, that are not terminated, and terminates those of them, who are staying inactive too long.

func (*Monitor) VerifySuspendedChannelsAndTryToTerminate

func (m *Monitor) VerifySuspendedChannelsAndTryToTerminate() error

VerifySuspendedChannelsAndTryToTerminate scans all suspended channels, and terminates those of them, who are staying suspended too long.

func (*Monitor) VerifySuspendedChannelsAndTryToUnsuspend

func (m *Monitor) VerifySuspendedChannelsAndTryToUnsuspend() error

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

func (m *Monitor) VerifyUnitsBasedChannels() error

VerifyUnitsBasedChannels checks all active units based channels for not using more units, than provided by quota and not exceeding over total deposit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL