Lock acquires an exclusive repository lock.
(ctx context.Context)
| 87 | |
| 88 | // Lock acquires an exclusive repository lock. |
| 89 | func (rl *RepositoryLock) Lock(ctx context.Context) error { |
| 90 | const retryDelay = 100 * time.Millisecond |
| 91 | |
| 92 | locked, err := rl.flock.TryLockContext(ctx, retryDelay) |
| 93 | if err != nil { |
| 94 | return fmt.Errorf("failed to acquire exclusive lock: %w", err) |
| 95 | } |
| 96 | if !locked { |
| 97 | return fmt.Errorf("failed to acquire exclusive lock within context timeout") |
| 98 | } |
| 99 | |
| 100 | return nil |
| 101 | } |
| 102 | |
| 103 | // RLock acquires a shared repository lock. |
| 104 | // Multiple processes can hold shared locks simultaneously. |
no outgoing calls
no test coverage detected