| 235 | } |
| 236 | |
| 237 | func (a *Auth) RecentRequestsSnapshot(now time.Time) []RecentRequestBucket { |
| 238 | out := make([]RecentRequestBucket, 0, recentRequestBucketCount) |
| 239 | if a == nil { |
| 240 | return out |
| 241 | } |
| 242 | |
| 243 | currentBucketID := recentRequestBucketID(now) |
| 244 | for i := recentRequestBucketCount - 1; i >= 0; i-- { |
| 245 | bucketID := currentBucketID - int64(i) |
| 246 | idx := recentRequestBucketIndex(bucketID) |
| 247 | bucket := a.recentRequests.buckets[idx] |
| 248 | entry := RecentRequestBucket{ |
| 249 | Time: formatRecentRequestBucketLabel(bucketID), |
| 250 | } |
| 251 | if bucket.bucketID == bucketID { |
| 252 | entry.Success = bucket.success |
| 253 | entry.Failed = bucket.failed |
| 254 | } |
| 255 | out = append(out, entry) |
| 256 | } |
| 257 | |
| 258 | return out |
| 259 | } |
| 260 | |
| 261 | // Clone shallow copies the Auth structure, duplicating maps to avoid accidental mutation. |
| 262 | func (a *Auth) Clone() *Auth { |