Set transitions to s, recording the transition time and clearing the last error. Same-state Set is a no-op (preserves Since/LastError).
(s State)
| 93 | // Set transitions to s, recording the transition time and clearing the |
| 94 | // last error. Same-state Set is a no-op (preserves Since/LastError). |
| 95 | func (t *Tracker) Set(s State) { |
| 96 | t.mu.Lock() |
| 97 | defer t.mu.Unlock() |
| 98 | if t.state == s { |
| 99 | return |
| 100 | } |
| 101 | t.state = s |
| 102 | t.since = time.Now() |
| 103 | t.lastErr = nil |
| 104 | } |
| 105 | |
| 106 | // Fail transitions to s and records err as the last error. Use this when |
| 107 | // entering Failed/Restarting after a failure so the supervisor's snapshot |