diff --git a/NetChris.Core/Patterns/IApplicationAdvisoryLockService.cs b/NetChris.Core/Patterns/IApplicationAdvisoryLockService.cs new file mode 100644 index 0000000..74f3f79 --- /dev/null +++ b/NetChris.Core/Patterns/IApplicationAdvisoryLockService.cs @@ -0,0 +1,28 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace NetChris.Core.Patterns; + +/// +/// Provides advisory lock services for a distributed application +/// +/// +/// This is inspired by Postgres advisory locks. See the links below for more information. +/// +/// +/// +public interface IApplicationAdvisoryLockService +{ + /// + /// Sets a transaction-level advisory lock for specified value + /// + /// + /// As the name implies, the lock is help for the duration of a transaction. There is no prescription where that + /// transaction lives or how it is managed. It is up to the application to ensure that the implementation uses some + /// mechanism (usually a database transaction), to ensure that the transaction is resolved (committed or rolled back) + /// in a timely manner. + /// + /// The advisory lock ID + /// The cancellation token used when first acquiring the lock + Task SetTransactionAdvisoryLockAsync(int lockId, CancellationToken cancellationToken); +} \ No newline at end of file