storj/satellite/accounting/common.go
Ivan Fraixedes ce26616647
satellite/accounting/live: Use Redis client directly
We have to adapt the live accounting to allow the packages that use it
to differentiate about errors for being able to ignore them and make our
satellite resilient to Redis downtime.

For differentiating errors we should make changes in the live accounting
but also in the storage/redis.Client, however, we may need to do some
dirty workarounds or break other parts of the implementation that
depends on it.

On the other hand we want to get rid of the storage/redis.Client because
it has more functionality that the one that we are using and some
process has been started to remove it.

Hence, we have refactored the live accounting to directly use the Redis
client library for later on (in a future commit) adapt the satellite for
being resilient to Redis downtime.

Last but not least, a test for expired bandwidth keys have been added
and with it a bug was spotted and fix it.

Change-Id: Ibd191522cd20f6a9a15e5ccb7beb83a678e530ff
2021-01-12 15:33:29 +01:00

51 lines
1.6 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package accounting
import (
"time"
"github.com/zeebo/errs"
"storj.io/common/storj"
)
// Constants for accounting_raw, accounting_rollup, and accounting_timestamps.
const (
// LastAtRestTally represents the accounting timestamp for the at-rest data calculation.
LastAtRestTally = "LastAtRestTally"
// LastBandwidthTally represents the accounting timestamp for the bandwidth allocation query.
LastBandwidthTally = "LastBandwidthTally"
// LastRollup represents the accounting timestamp for rollup calculations.
LastRollup = "LastRollup"
)
var (
// ErrInvalidArgument is returned when a function argument has an invalid
// business domain value.
ErrInvalidArgument = errs.Class("invalid argument")
// ErrSystemOrNetError is returned when the used storage backend returns an
// internal system or network error.
ErrSystemOrNetError = errs.Class("backend system error")
// ErrKeyNotFound is returned when the key is not found in the cache.
ErrKeyNotFound = errs.Class("key not found")
// ErrUnexpectedValue is returned when an unexpected value according the
// business domain is in the cache.
ErrUnexpectedValue = errs.Class("unexpected value")
)
// CSVRow represents data from QueryPaymentInfo without exposing dbx.
type CSVRow struct {
NodeID storj.NodeID
NodeCreationDate time.Time
AtRestTotal float64
GetRepairTotal int64
PutRepairTotal int64
GetAuditTotal int64
PutTotal int64
GetTotal int64
Wallet string
Disqualified *time.Time
}