Forum Discussion

Rushabh1035's avatar
Rushabh1035
New Contributor
5 years ago

Is there a way to check if there's already a distributed lock in consul for particular lock name?

I'm trying to check if there's a distributed lock in consul for a particular lock name using consul client (https://www.nuget.org/packages/Consul/).

Currently the only way to achieve it is to try to acquire a lock for that lock name, using ConsulClient.AcquireLock(). However if the lock exists AcquireLock method doesn't return a result, but instead waits for the consul lock to be released and right then locks it and returns a result.

await new ConsulClient().AcquireLock("lockNameExample");

Is there a way to retrieve the list of all consul locks or maybe some other way to check if there's a lock in consul for the given lock name?