Track records boundary usage for a workspace.
(workspaceID, ownerID uuid.UUID, allowed, denied int64)
| 53 | |
| 54 | // Track records boundary usage for a workspace. |
| 55 | func (t *Tracker) Track(workspaceID, ownerID uuid.UUID, allowed, denied int64) { |
| 56 | t.mu.Lock() |
| 57 | defer t.mu.Unlock() |
| 58 | |
| 59 | t.workspaces[workspaceID] = struct{}{} |
| 60 | t.users[ownerID] = struct{}{} |
| 61 | t.workspacesDelta[workspaceID] = struct{}{} |
| 62 | t.usersDelta[ownerID] = struct{}{} |
| 63 | t.allowedRequests += allowed |
| 64 | t.deniedRequests += denied |
| 65 | t.usageSinceLastFlush = true |
| 66 | } |
| 67 | |
| 68 | // FlushToDB writes stats to the database. For unique counts, cumulative values |
| 69 | // are used on UPDATE (replacing the DB value) while delta values are used on |