Complete autonomous recovery controls
This commit is contained in:
@@ -61,6 +61,17 @@ type QuotaReceipt struct {
|
||||
At time.Time `json:"at"`
|
||||
}
|
||||
|
||||
// QuotaWindows publishes the two routing windows from the same additive
|
||||
// per-lease receipts used by the scheduler.
|
||||
type QuotaWindows struct {
|
||||
FiveHour map[string]float64 `json:"five_hour"`
|
||||
Weekly map[string]float64 `json:"weekly"`
|
||||
}
|
||||
|
||||
func ProjectQuotaWindows(events []domain.Event, now time.Time) QuotaWindows {
|
||||
return QuotaWindows{FiveHour: AggregateQuota(events, now.Add(-5*time.Hour), now), Weekly: AggregateQuota(events, now.Add(-7*24*time.Hour), now)}
|
||||
}
|
||||
|
||||
// AggregateQuota sums native receipts in the requested window. It does not
|
||||
// de-duplicate rotations or use a cumulative session total.
|
||||
func AggregateQuota(events []domain.Event, from, to time.Time) map[string]float64 {
|
||||
|
||||
Reference in New Issue
Block a user