Interface IServerBandwidthReportService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
The operator's side of the bandwidth tables: the page's read, and the rollup and retention the Control Panel runs on a timer.
public interface IServerBandwidthReportService
Remarks
One pass at a time across every panel. The rollup and each retention batch run in a
transaction that first takes pg_try_advisory_xact_lock; a panel that does not get
it skips the pass. The numbers would be right without it — every hour row is recomputed
from its minutes and SET, never added to — but two panels upserting the same hour rows in
whatever order their GROUP BY produced can deadlock each other, and two retention passes
would fight over the same victims. It is a TRANSACTION-level lock on purpose: pooled
connections are returned without a reset (NoResetOnClose), so a session-level lock
would outlive the pass on a connection somebody else later borrows.
Methods
FetchReportAsync(ServerBandwidthRange, int, string?, CancellationToken)
Everything the bandwidth page shows, read in one REPEATABLE READ snapshot against one database clock.
Task<DatabaseResult<ServerBandwidthReport>> FetchReportAsync(ServerBandwidthRange range, int scopeKind, string? scopeName, CancellationToken cancellationToken = default)
Parameters
rangeServerBandwidthRangeThe charted range.
scopeKindintChart one tier (ServerBandwidthKind), or 0 for all.
scopeNamestringChart one server of
scopeKind, or null.cancellationTokenCancellationTokenCancellation token.
Returns
PruneAsync(int, int, CancellationToken)
Deletes minute rows older than MinuteRetentionDays and hour rows older than HourRetentionMonths, in bounded batches.
Task<DatabaseResult<ServerBandwidthPruneResult>> PruneAsync(int maxMinuteHours, int maxHourBatches, CancellationToken cancellationToken = default)
Parameters
maxMinuteHoursintThe most whole hours of minutes to prune this pass.
maxHourBatchesintThe most delete batches of expired hour rows this pass.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Minutes go one whole hour per transaction, and that transaction first rolls the hour it is about to delete, so pruning can never lose traffic the rollup had not reached, and no hour is ever left with some of its minutes gone (which a later recompute would read as a smaller hour).
RollupAsync(bool, CancellationToken)
Recomputes hour rows from the minutes: the last
RollupWindowHours hours, or every hour that still has
minutes when catchUp is set (the first pass after a panel starts,
covering however long no panel was running).
Task<DatabaseResult<ServerBandwidthRollupResult>> RollupAsync(bool catchUp, CancellationToken cancellationToken = default)
Parameters
catchUpboolRoll every hour that has minute rows, not just the recent window.
cancellationTokenCancellationTokenCancellation token.