[Feature] Only support `async` methods in `IDistributedLock`
dhickie opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
When implementing a DynamoDb implementation of IDistributedLock
, I came across the issue that the .NET SDK for Dynamo DB doesn't support synchronous methods. As a result, when implementing ObtainLock
, there's a risk of deadlock when doing the following:
public bool ObtainLock(string resource)
{
return ObtainLockAsync(resource, CancellationToken.None).GetAwaiter().GetResult();
}
Describe the solution you'd like
Drop the synchronous methods from the interface. Implementations that don't have async
methods can use Task.FromResult
as a workaround. This would, however, also mean that the lambda passed to the Timer
instance in TimedOutboxSweeper
would also need to be async.
Additional context
Builds on the recent distributed lock work by @preardon.
@iancooper I'm happy to drop sync flows if you are. let me know and I'll get on it
Do it