bandwidth

package
v1.29.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package bandwidth implements bandwidth usage rollup loop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.16.0

type Config struct {
	Interval time.Duration `help:"how frequently bandwidth usage rollups are calculated" default:"1h0m0s"`
}

Config defines parameters for storage node Collector.

type DB

type DB interface {
	Add(ctx context.Context, satelliteID storj.NodeID, action pb.PieceAction, amount int64, created time.Time) error
	// MonthSummary returns summary of the current months bandwidth usages.
	MonthSummary(ctx context.Context, now time.Time) (int64, error)
	Rollup(ctx context.Context) (err error)
	// Summary returns summary of bandwidth usages.
	Summary(ctx context.Context, from, to time.Time) (*Usage, error)
	// EgressSummary returns summary of egress bandwidth usages.
	EgressSummary(ctx context.Context, from, to time.Time) (*Usage, error)
	// IngressSummary returns summary of ingress bandwidth usages.
	IngressSummary(ctx context.Context, from, to time.Time) (*Usage, error)
	// SatelliteSummary returns aggregated bandwidth usage for a particular satellite.
	SatelliteSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
	// SatelliteEgressSummary returns egress bandwidth usage for a particular satellite.
	SatelliteEgressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
	// SatelliteIngressSummary returns ingress bandwidth usage for a particular satellite.
	SatelliteIngressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
	SummaryBySatellite(ctx context.Context, from, to time.Time) (map[storj.NodeID]*Usage, error)
	// GetDailyRollups returns slice of daily bandwidth usage rollups for provided time range,
	// sorted in ascending order.
	GetDailyRollups(ctx context.Context, from, to time.Time) ([]UsageRollup, error)
	// GetDailySatelliteRollups returns slice of daily bandwidth usage for provided time range,
	// sorted in ascending order for a particular satellite.
	GetDailySatelliteRollups(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) ([]UsageRollup, error)
}

DB contains information about bandwidth usage.

architecture: Database

type Egress added in v0.21.0

type Egress struct {
	Repair int64 `json:"repair"`
	Audit  int64 `json:"audit"`
	Usage  int64 `json:"usage"`
}

Egress stores info about storage node egress usage.

type Ingress added in v0.21.0

type Ingress struct {
	Repair int64 `json:"repair"`
	Usage  int64 `json:"usage"`
}

Ingress stores info about storage node ingress usage.

type Service added in v0.16.0

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

Service implements the bandwidth usage rollup service.

architecture: Chore

func NewService added in v0.16.0

func NewService(log *zap.Logger, db DB, config Config) *Service

NewService creates a new bandwidth service.

func (*Service) Close added in v0.16.0

func (service *Service) Close() (err error)

Close stops the background process for rollups of bandwidth usage.

func (*Service) Rollup added in v0.16.0

func (service *Service) Rollup(ctx context.Context) (err error)

Rollup calls bandwidth DB Rollup method and logs any errors.

func (*Service) Run added in v0.16.0

func (service *Service) Run(ctx context.Context) (err error)

Run starts the background process for rollups of bandwidth usage.

type Usage

type Usage struct {
	Invalid int64
	Unknown int64

	Put       int64
	Get       int64
	GetAudit  int64
	GetRepair int64
	PutRepair int64
	Delete    int64
}

Usage contains bandwidth usage information based on the type.

func TotalMonthlySummary added in v0.10.0

func TotalMonthlySummary(ctx context.Context, db DB) (*Usage, error)

TotalMonthlySummary returns total bandwidth usage for current month.

func (*Usage) Add

func (usage *Usage) Add(b *Usage)

Add adds another usage to this one.

func (*Usage) Include

func (usage *Usage) Include(action pb.PieceAction, amount int64)

Include adds specified action to the appropriate field.

func (*Usage) Total

func (usage *Usage) Total() int64

Total sums all type of bandwidths.

type UsageRollup added in v0.21.0

type UsageRollup struct {
	Egress        Egress    `json:"egress"`
	Ingress       Ingress   `json:"ingress"`
	Delete        int64     `json:"delete"`
	IntervalStart time.Time `json:"intervalStart"`
}

UsageRollup contains rolluped bandwidth usage.

Jump to

Keyboard shortcuts

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