UsageTracker tracks and de-bounces updates to workspace usage activity. It keeps an internal map of workspace IDs that have been used and periodically flushes this to its configured Store.
| 28 | // It keeps an internal map of workspace IDs that have been used and |
| 29 | // periodically flushes this to its configured Store. |
| 30 | type UsageTracker struct { |
| 31 | log slog.Logger // you know, for logs |
| 32 | flushLock sync.Mutex // protects m |
| 33 | flushErrors int // tracks the number of consecutive errors flushing |
| 34 | m *uuidSet // stores workspace ids |
| 35 | s Store // for flushing data |
| 36 | tickCh <-chan time.Time // controls flush interval |
| 37 | stopTick func() // stops flushing |
| 38 | stopCh chan struct{} // signals us to stop |
| 39 | stopOnce sync.Once // because you only stop once |
| 40 | doneCh chan struct{} // signifies that we have stopped |
| 41 | flushCh chan int // used for testing. |
| 42 | } |
| 43 | |
| 44 | // NewTracker returns a new Tracker. It is the caller's responsibility |
| 45 | // to call Close(). |
nothing calls this directly
no outgoing calls
no test coverage detected