(deadline int64)
| 95 | } |
| 96 | |
| 97 | func (m *ActiveUsers) ActiveUsers(deadline int64) []string { |
| 98 | m.mu.RLock() |
| 99 | active := make([]string, 0, len(m.timestamps)) |
| 100 | defer m.mu.RUnlock() |
| 101 | for userID, ts := range m.timestamps { |
| 102 | if ts.Load() > deadline { |
| 103 | active = append(active, userID) |
| 104 | } |
| 105 | } |
| 106 | return active |
| 107 | } |
| 108 | |
| 109 | // ActiveUsersCleanupService tracks active users, and periodically purges inactive ones while running. |
| 110 | type ActiveUsersCleanupService struct { |