EnqueueAction adds a pending action to a session's queue. Poison actions are always inserted at the front (highest priority).
(sessionID string, action *PendingAction)
| 149 | // EnqueueAction adds a pending action to a session's queue. |
| 150 | // Poison actions are always inserted at the front (highest priority). |
| 151 | func (m *Manager) EnqueueAction(sessionID string, action *PendingAction) bool { |
| 152 | sess := m.Get(sessionID) |
| 153 | if sess == nil { |
| 154 | return false |
| 155 | } |
| 156 | sess.mu.Lock() |
| 157 | defer sess.mu.Unlock() |
| 158 | if action.Type == ActionPoison { |
| 159 | sess.pendingActions = append([]*PendingAction{action}, sess.pendingActions...) |
| 160 | } else { |
| 161 | sess.pendingActions = append(sess.pendingActions, action) |
| 162 | } |
| 163 | return true |
| 164 | } |
| 165 | |
| 166 | // DequeueAction removes and returns the next pending action. |
| 167 | // Poison actions have priority: if any exist, the first poison is returned. |
no test coverage detected