monitor

package
v0.0.0-...-f7edce5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigProviders = fx.Options(
	fx.Provide(func(cfg agent.MonitorConfig) AcceptedConfig {
		value := cfg.AcceptedShares
		return AcceptedConfig{
			Enabled: value.Enabled,
			Period:  value.Period,
		}
	}),

	fx.Provide(func(cfg agent.MonitorConfig) HighLoadConfig {
		value := cfg.HighLoad
		return HighLoadConfig{
			Enabled:      value.Enabled,
			Period:       value.Period,
			HighLoadMark: value.HighLoadMark,
		}
	}),

	fx.Provide(func(cfg agent.MonitorConfig) HighTempConfig {
		value := cfg.HighTemp
		return HighTempConfig{
			Enabled:  value.Enabled,
			Period:   value.Period,
			HighTemp: value.HighTemp,
		}
	}),

	fx.Provide(func(cfg agent.MonitorConfig) CGMQuitConfig {
		value := cfg.CGMQuit
		return CGMQuitConfig{
			Enabled: value.Enabled,
			Period:  value.Period.Duration,
		}
	}),

	fx.Provide(func(cfg agent.MonitorConfig) RebootConfig {
		value := cfg.Reboot
		return RebootConfig{
			Enabled: value.Enabled,
			Period:  value.Period.Duration,
		}
	}),

	fx.Provide(func(cfg agent.MonitorConfig) LowMemoryConfig {
		value := cfg.LowMemory
		return LowMemoryConfig{
			Enabled:   value.Enabled,
			Period:    value.Period,
			LowMemory: value.LowMemory,
		}
	}),

	fx.Provide(func(cfg agent.MonitorConfig) NtpdateConfig {
		value := cfg.Ntpdate
		return NtpdateConfig{
			Enabled: value.Enabled,
			Period:  value.Period,
		}
	}),
)

Copy the config from the agent data source in order to keep the dependency between the config file (Entity) and the monitor layer clean via a DTO. Managed through the dependency injection so it is all cleanly done.

Functions

This section is empty.

Types

type AcceptedConfig

type AcceptedConfig struct {
	Enabled bool
	Period  time.Duration
}

type CGMQuitConfig

type CGMQuitConfig struct {
	Enabled bool
	Period  time.Duration
}

type Data

type Data struct {
	Enabled bool
	Period  time.Duration
	OnTick  OnTick
}

func (*Data) GetPeriod

func (data *Data) GetPeriod() time.Duration

func (*Data) IsEnabled

func (data *Data) IsEnabled() bool

func (*Data) NewTickerFunc

func (data *Data) NewTickerFunc() TickerFunc

func (*Data) Start

func (data *Data) Start(ctx context.Context, wg *sync.WaitGroup, tickerFunc TickerFunc)

type Group

type Group struct {
	fx.In
	Monitors []Monitor `group:"monitor"`
}

type HighLoadConfig

type HighLoadConfig struct {
	Enabled      bool
	Period       time.Duration
	HighLoadMark float64
}

type HighTempConfig

type HighTempConfig struct {
	Enabled  bool
	Period   time.Duration
	HighTemp float64
}

type LowMemoryConfig

type LowMemoryConfig struct {
	Enabled   bool
	Period    time.Duration
	LowMemory float64
}

type Manager

type Manager interface {
	Start()
	Stop()
}

func NewManager

func NewManager(g Group) Manager

There is a little fx magic here. Group gets magically populated with a list of monitors because those are provided in the module declaration below and we use the fx 'group' functionality to make that happen.

type ManagerData

type ManagerData struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*ManagerData) Start

func (mm *ManagerData) Start()

func (*ManagerData) Stop

func (mm *ManagerData) Stop()

type MockManager

type MockManager struct {
	CalledStart bool
	CalledStop  bool
}

func NewMockManager

func NewMockManager() MockManager

func (*MockManager) Start

func (mm *MockManager) Start()

func (*MockManager) Stop

func (mm *MockManager) Stop()

type Monitor

type Monitor interface {
	Start(ctx context.Context, wg *sync.WaitGroup, tickerFunc TickerFunc)
	IsEnabled() bool
	GetPeriod() time.Duration
	NewTickerFunc() TickerFunc
}

type NtpdateConfig

type NtpdateConfig struct {
	Enabled bool
	Period  time.Duration
	Server  string
}

type OnTick

type OnTick func() TickerFunc

type RebootConfig

type RebootConfig struct {
	Enabled bool
	Period  time.Duration
}

type Result

type Result struct {
	fx.Out
	Monitor Monitor `group:"monitor"`
}

func NewAcceptedMonitor

func NewAcceptedMonitor(config AcceptedConfig, client miner.Client, reboot os.Reboot) Result

func NewCGMQuitMonitor

func NewCGMQuitMonitor(config CGMQuitConfig, client miner.Client) Result

func NewHighTempMonitor

func NewHighTempMonitor(config HighTempConfig, client miner.Client, miner os.Miner) Result

func NewLoadMonitor

func NewLoadMonitor(config HighLoadConfig, retriever os.StatRetriever, reboot os.Reboot) Result

func NewLowMemoryMonitor

func NewLowMemoryMonitor(config LowMemoryConfig, memInfo os.MemInfo, reboot os.Reboot) Result

func NewNtpdateMonitor

func NewNtpdateMonitor(config NtpdateConfig, ntpdate os.Ntpdate) Result

func NewRebootMonitor

func NewRebootMonitor(config RebootConfig, reboot os.Reboot) Result

type Stop

type Stop func()

func StartMonitors

func StartMonitors(parent context.Context, monitors []Monitor) Stop

type TickerFunc

type TickerFunc func(ctx context.Context)

Jump to

Keyboard shortcuts

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