Documentation ¶
Overview ¶
Package bandwidth system keeps track of bandwidth usage as reported by order limits and orders.
Package bandwidth implements bandwidth usage rollup loop.
Index ¶
- type Cache
- func (c *Cache) Add(ctx context.Context, satelliteID storj.NodeID, action pb.PieceAction, ...) (err error)
- func (c *Cache) AddBatch(ctx context.Context, usages map[CacheKey]*Usage) (err error)
- func (c *Cache) EgressSummary(ctx context.Context, from, to time.Time) (*Usage, error)
- func (c *Cache) GetDailyRollups(ctx context.Context, from, to time.Time) ([]UsageRollup, error)
- func (c *Cache) GetDailySatelliteRollups(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) ([]UsageRollup, error)
- func (c *Cache) IngressSummary(ctx context.Context, from, to time.Time) (*Usage, error)
- func (c *Cache) MonthSummary(ctx context.Context, now time.Time) (int64, error)
- func (c *Cache) Persist(ctx context.Context) (err error)
- func (c *Cache) SatelliteEgressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
- func (c *Cache) SatelliteIngressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
- func (c *Cache) SatelliteSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
- func (c *Cache) Summary(ctx context.Context, from, to time.Time) (*Usage, error)
- func (c *Cache) SummaryBySatellite(ctx context.Context, from, to time.Time) (map[storj.NodeID]*Usage, error)
- type CacheKey
- type Config
- type DB
- type Egress
- type Ingress
- type Service
- type Usage
- func (usage *Usage) Add(b *Usage)
- func (usage *Usage) Egress() *Usage
- func (usage *Usage) Include(action pb.PieceAction, amount int64)
- func (usage *Usage) Ingress() *Usage
- func (usage *Usage) Rollup(intervalStart time.Time) *UsageRollup
- func (usage *Usage) ToEgress() Egress
- func (usage *Usage) ToIngress() Ingress
- func (usage *Usage) Total() int64
- type UsageRollup
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶ added in v1.104.1
type Cache struct {
// contains filtered or unexported fields
}
Cache stores bandwidth usage in memory and persists it to the database. Currently, it only acts as a write cache.
func (*Cache) Add ¶ added in v1.104.1
func (c *Cache) Add(ctx context.Context, satelliteID storj.NodeID, action pb.PieceAction, amount int64, created time.Time) (err error)
Add adds a bandwidth usage to the cache.
func (*Cache) EgressSummary ¶ added in v1.104.1
EgressSummary returns the summary of egress bandwidth usages.
func (*Cache) GetDailyRollups ¶ added in v1.104.1
GetDailyRollups returns the slice of daily bandwidth usage rollups for the provided time range, sorted in ascending order.
func (*Cache) GetDailySatelliteRollups ¶ added in v1.104.1
func (c *Cache) GetDailySatelliteRollups(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) ([]UsageRollup, error)
GetDailySatelliteRollups returns the slice of daily bandwidth usage for the provided time range, sorted in ascending order for a particular satellite.
func (*Cache) IngressSummary ¶ added in v1.104.1
IngressSummary returns the summary of ingress bandwidth usages.
func (*Cache) MonthSummary ¶ added in v1.104.1
MonthSummary returns the summary of the current month's bandwidth usages.
func (*Cache) SatelliteEgressSummary ¶ added in v1.104.1
func (c *Cache) SatelliteEgressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
SatelliteEgressSummary returns the egress bandwidth usage for a particular satellite.
func (*Cache) SatelliteIngressSummary ¶ added in v1.104.1
func (c *Cache) SatelliteIngressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
SatelliteIngressSummary returns the ingress bandwidth usage for a particular satellite.
func (*Cache) SatelliteSummary ¶ added in v1.104.1
func (c *Cache) SatelliteSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (*Usage, error)
SatelliteSummary returns the aggregated bandwidth usage for a particular satellite.
type Config ¶ added in v0.16.0
type Config struct {
Interval time.Duration `help:"how frequently bandwidth usage cache should be synced with the db" default:"1h0m0s" testDefault:"1s"`
}
Config defines parameters for storage node Collector.
type DB ¶
type DB interface { Writer // MonthSummary returns summary of the current months bandwidth usages. MonthSummary(ctx context.Context, now time.Time) (int64, 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 Service ¶ added in v0.16.0
Service implements the bandwidth usage rollup service.
architecture: Chore
func NewService ¶ added in v0.16.0
NewService creates a new bandwidth service.
func (*Service) Close ¶ added in v0.16.0
Close stops 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
TotalMonthlySummary returns total bandwidth usage for current month.
func (*Usage) Include ¶
func (usage *Usage) Include(action pb.PieceAction, amount int64)
Include adds specified action to the appropriate field.
func (*Usage) Rollup ¶ added in v1.104.1
func (usage *Usage) Rollup(intervalStart time.Time) *UsageRollup
Rollup returns rolluped bandwidth usage.