MCPcopy
hub / github.com/caddyserver/certmagic / tryAcquireLock

Function tryAcquireLock

storage.go:318–331  ·  view source on GitHub ↗
(ctx context.Context, storage Storage, lockKey string)

Source from the content-addressed store, hash-verified

316}
317
318func tryAcquireLock(ctx context.Context, storage Storage, lockKey string) (bool, error) {
319 locker, ok := storage.(TryLocker)
320 if !ok {
321 return false, fmt.Errorf("%T does not implement TryLocker", storage)
322 }
323
324 ok, err := locker.TryLock(ctx, lockKey)
325 if ok && err == nil {
326 locksMu.Lock()
327 locks[lockKey] = storage
328 locksMu.Unlock()
329 }
330 return ok, err
331}
332
333func releaseLock(ctx context.Context, storage Storage, lockKey string) error {
334 err := storage.Unlock(context.WithoutCancel(ctx), lockKey)

Callers 1

updateARIMethod · 0.85

Calls 3

TryLockMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…