| 27 | var lockerMux = sync.Mutex{} |
| 28 | |
| 29 | func TryLock(key, identifier string) (ok bool) { |
| 30 | if locker == nil { |
| 31 | panic("no locker is registered") |
| 32 | } |
| 33 | |
| 34 | _, filename, line, _ := runtime.Caller(1) |
| 35 | slog.Debug("attempting to try lock", "key", key, "identifier", identifier, "caller", fmt.Sprintf("%s:%d", filename, line)) |
| 36 | defer slog.Debug("try lock returned", "key", key, "identifier", identifier, "locked", ok, "caller", fmt.Sprintf("%s:%d", filename, line)) |
| 37 | |
| 38 | ok = locker.TryLock(key, identifier) |
| 39 | return ok |
| 40 | } |
| 41 | |
| 42 | func Lock(key, identifier string) { |
| 43 | if locker == nil { |