rollbackDrained restores every session named in snaps to its pre-drain state. Used on failure paths where the batch never reached the exit server (transport error, Apps Script rejection, etc.) so the SYN/payload can be retransmitted on the next poll instead of being silently lost.
(snaps map[[frame.SessionIDLen]byte]*session.DrainSnapshot)
| 1222 | // (transport error, Apps Script rejection, etc.) so the SYN/payload can be |
| 1223 | // retransmitted on the next poll instead of being silently lost. |
| 1224 | func (c *Client) rollbackDrained(snaps map[[frame.SessionIDLen]byte]*session.DrainSnapshot) { |
| 1225 | if len(snaps) == 0 { |
| 1226 | return |
| 1227 | } |
| 1228 | c.mu.Lock() |
| 1229 | type pending struct { |
| 1230 | s *session.Session |
| 1231 | snap *session.DrainSnapshot |
| 1232 | } |
| 1233 | out := make([]pending, 0, len(snaps)) |
| 1234 | for id, snap := range snaps { |
| 1235 | if s, ok := c.sessions[id]; ok { |
| 1236 | out = append(out, pending{s: s, snap: snap}) |
| 1237 | } |
| 1238 | } |
| 1239 | c.mu.Unlock() |
| 1240 | for _, p := range out { |
| 1241 | p.s.RollbackDrain(p.snap) |
| 1242 | } |
| 1243 | } |
| 1244 | |
| 1245 | func (c *Client) releaseInFlight(ids [][frame.SessionIDLen]byte) { |
| 1246 | c.mu.Lock() |