billing

package
v0.0.0-...-cb3ca1d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInput = errors.New("one or more input parameters is wrong")
)

Billing monitor specific errors.

Functions

This section is empty.

Types

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 time.Duration, db *reform.DB,
	logger *util.Logger, pc *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) VerifySecondsBasedChannels

func (m *Monitor) VerifySecondsBasedChannels() error

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

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