(duration time.Duration, sessionID string)
| 141 | } |
| 142 | |
| 143 | func (d *sessionsDict) startTimer(duration time.Duration, sessionID string) { |
| 144 | d.Lock() |
| 145 | defer d.Unlock() |
| 146 | t, ok := d.timer[sessionID] |
| 147 | if ok { |
| 148 | if !t.Stop() { |
| 149 | <-t.C |
| 150 | } |
| 151 | t.Reset(duration) |
| 152 | return |
| 153 | } |
| 154 | d.timer[sessionID] = time.AfterFunc(duration, func() { |
| 155 | d.deleteSession(sessionID) |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | // addCompletedSessionStage records that a session has completed an auth stage |
| 160 | // also starts a timer to delete the session once done. |