Unlock releases all locks in reverse order of acquisition. Releasing in reverse order is a best practice for multi-lock scenarios. Parameters: - ctx: The context for managing the unlock request lifecycle. Returns an error if any unlock operation fails.
(ctx context.Context)
| 272 | // - ctx: The context for managing the unlock request lifecycle. |
| 273 | // Returns an error if any unlock operation fails. |
| 274 | func (m *MultiLocker) Unlock(ctx context.Context) error { |
| 275 | var lastErr error |
| 276 | |
| 277 | // Release locks in reverse order |
| 278 | for i := len(m.lockers) - 1; i >= 0; i-- { |
| 279 | if err := m.lockers[i].Unlock(ctx); err != nil { |
| 280 | lastErr = err |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return lastErr |
| 285 | } |
| 286 | |
| 287 | // rollback releases locks that were successfully acquired before a failure. |
| 288 | // Parameters: |