Documentation
¶
Index ¶
- type Aggregator
- func (a *Aggregator) AddReport(ctx context.Context, serverInfo *node.Server, protocol string, ...) error
- func (a *Aggregator) AddReportAt(ctx context.Context, serverInfo *node.Server, protocol string, ...) error
- func (a *Aggregator) FlushDueBuckets(ctx context.Context, now time.Time) error
- func (a *Aggregator) FlushServerReports(ctx context.Context) error
- func (a *Aggregator) RecordServerReport(ctx context.Context, serverID int64, reportedAt time.Time) error
- type Deps
- type UserTraffic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
func New ¶
func New(deps Deps) *Aggregator
func (*Aggregator) AddReport ¶
func (a *Aggregator) AddReport(ctx context.Context, serverInfo *node.Server, protocol string, logs []UserTraffic) error
func (*Aggregator) AddReportAt ¶
func (a *Aggregator) AddReportAt(ctx context.Context, serverInfo *node.Server, protocol string, logs []UserTraffic, now time.Time) error
func (*Aggregator) FlushDueBuckets ¶
func (*Aggregator) FlushServerReports ¶
func (a *Aggregator) FlushServerReports(ctx context.Context) error
func (*Aggregator) RecordServerReport ¶ added in v1.19.0
func (a *Aggregator) RecordServerReport(ctx context.Context, serverID int64, reportedAt time.Time) error
RecordServerReport records the latest heartbeat in Redis. The scheduled traffic flush persists all servers' latest timestamps to the database in one batch, avoiding a database write for every node heartbeat.
type Deps ¶ added in v1.15.0
type Deps struct {
Store repository.Store
Redis *redis.Client
// TrafficReportThreshold reads the runtime-mutable minimum report size;
// nil means no minimum.
TrafficReportThreshold func() int64
// Multiplier returns the node traffic multiplier in effect at the given
// time; nil means no multiplier is configured.
Multiplier func(at time.Time) float32
}
Deps declares the aggregator's collaborators; callers build it from their own composition (the queue logic and the network module both use it).
type UserTraffic ¶
Click to show internal directories.
Click to hide internal directories.