CleanUpOwnLocks immediately cleans up all current locks obtained by this process. Since this does not cancel the operations that the locks are synchronizing, this should be called only immediately before process exit. Errors are only reported if a logger is given.
(ctx context.Context, logger *zap.Logger)
| 291 | // called only immediately before process exit. |
| 292 | // Errors are only reported if a logger is given. |
| 293 | func CleanUpOwnLocks(ctx context.Context, logger *zap.Logger) { |
| 294 | locksMu.Lock() |
| 295 | defer locksMu.Unlock() |
| 296 | for lockKey, storage := range locks { |
| 297 | if err := storage.Unlock(ctx, lockKey); err != nil { |
| 298 | logger.Error("unable to clean up lock in storage backend", |
| 299 | zap.Any("storage", storage), |
| 300 | zap.String("lock_key", lockKey), |
| 301 | zap.Error(err)) |
| 302 | continue |
| 303 | } |
| 304 | delete(locks, lockKey) |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | func acquireLock(ctx context.Context, storage Storage, lockKey string) error { |
| 309 | err := storage.Lock(ctx, lockKey) |