Skip to content

Commit 163fe5f

Browse files
Added GetAllUsernames for cleanup in main
1 parent 666626c commit 163fe5f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/session/utils.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ func (s *Session) serializeSessionForRedis() map[string]interface{} {
1717
"failed": s.FailedCount,
1818
}
1919
}
20+
21+
/* returns all the usernames in the manager */
22+
func (m *Manager) GetAllUsernames() []string {
23+
/* thread safety of manager */
24+
m.mutex.Lock()
25+
defer m.mutex.Unlock()
26+
27+
/* create and fill slice for usernames */
28+
usernames := make([]string, 0, len(m.sessionsMap))
29+
for _, session := range m.sessionsMap {
30+
usernames = append(usernames, session.Username)
31+
}
32+
33+
return usernames
34+
}

0 commit comments

Comments
 (0)