(username, filePath string)
| 16 | ) |
| 17 | |
| 18 | func ScheduleDebouncedLog(username, filePath string) { |
| 19 | debounceMu.Lock() |
| 20 | defer debounceMu.Unlock() |
| 21 | |
| 22 | if state, exists := debounceStates[username]; exists { |
| 23 | state.Mu.Lock() |
| 24 | if state.Timer != nil { |
| 25 | state.Timer.Stop() |
| 26 | } |
| 27 | state.Mu.Unlock() |
| 28 | } |
| 29 | |
| 30 | state := &types.UserDebounceState{ |
| 31 | FilePath: filePath, |
| 32 | Username: username, |
| 33 | } |
| 34 | |
| 35 | state.Timer = time.AfterFunc(debounceDelay, func() { |
| 36 | createWriteFileLog(username, filePath) |
| 37 | |
| 38 | debounceMu.Lock() |
| 39 | delete(debounceStates, username) |
| 40 | debounceMu.Unlock() |
| 41 | }) |
| 42 | |
| 43 | debounceStates[username] = state |
| 44 | } |
| 45 | |
| 46 | func TriggerPendingLog(username, filePath string) { |
| 47 | debounceMu.Lock() |
no test coverage detected