downtime

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DetectionInterval          time.Duration `help:"how often to run the downtime detection chore." releaseDefault:"1h0s" devDefault:"30s"`
	EstimationInterval         time.Duration `help:"how often to run the downtime estimation chore" releaseDefault:"1h0s" devDefault:"30s"`
	EstimationBatchSize        int           `help:"the downtime estimation chore should check this many offline nodes" releaseDefault:"1000" devDefault:"100"`
	EstimationConcurrencyLimit int           `help:"max number of concurrent connections in estimation chore" default:"10"`
}

Config for the chore.

type DB

type DB interface {
	// Add adds a record for a particular node ID with the amount of time it has been offline.
	Add(ctx context.Context, nodeID storj.NodeID, trackedTime time.Time, timeOffline time.Duration) error
	// GetOfflineTime gets the total amount of offline time for a node within a certain timeframe.
	// "total offline time" is defined as the sum of all offline time windows that begin inside the provided time window.
	// An offline time window that began before `begin` but that overlaps with the provided time window is not included.
	// An offline time window that begins within the provided time window, but that extends beyond `end` is included.
	GetOfflineTime(ctx context.Context, nodeID storj.NodeID, begin, end time.Time) (time.Duration, error)
}

DB implements basic operations for downtime tracking service

architecture: Database

type DetectionChore

type DetectionChore struct {
	Loop *sync2.Cycle
	// contains filtered or unexported fields
}

DetectionChore looks for nodes that have not checked in and tries to contact them.

architecture: Chore

func NewDetectionChore

func NewDetectionChore(log *zap.Logger, config Config, overlay *overlay.Service, service *Service) *DetectionChore

NewDetectionChore instantiates DetectionChore.

func (*DetectionChore) Close

func (chore *DetectionChore) Close() error

Close closes chore.

func (*DetectionChore) Run

func (chore *DetectionChore) Run(ctx context.Context) (err error)

Run starts the chore.

type EstimationChore added in v0.29.8

type EstimationChore struct {
	Loop *sync2.Cycle
	// contains filtered or unexported fields
}

EstimationChore estimates how long nodes have been offline.

architecture: Chore

func NewEstimationChore added in v0.29.8

func NewEstimationChore(log *zap.Logger, config Config, overlay *overlay.Service, service *Service, db DB) *EstimationChore

NewEstimationChore instantiates EstimationChore.

func (*EstimationChore) Close added in v0.29.8

func (chore *EstimationChore) Close() error

Close closes chore.

func (*EstimationChore) Run added in v0.29.8

func (chore *EstimationChore) Run(ctx context.Context) (err error)

Run starts the chore.

type NodeOfflineTime

type NodeOfflineTime struct {
	NodeID      storj.NodeID
	TrackedAt   time.Time
	TimeOffline time.Duration
}

NodeOfflineTime represents a record in the nodes_offline_time table

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a service for downtime checking.

architecture: Service

func NewService

func NewService(log *zap.Logger, overlay *overlay.Service, contact *contact.Service) *Service

NewService creates a new downtime tracking service.

func (*Service) CheckAndUpdateNodeAvailability

func (service *Service) CheckAndUpdateNodeAvailability(ctx context.Context, nodeurl storj.NodeURL) (success bool, err error)

CheckAndUpdateNodeAvailability tries to ping the supplied address and updates the uptime based on ping success or failure. Returns true if the ping and uptime updates are successful.

func (*Service) Close

func (service *Service) Close() error

Close closes resources

Jump to

Keyboard shortcuts

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