d22eb1617f
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 9m58s
Introduce IUserPaymentLock to serialize payment initiate and verify flows per user, preventing concurrent duplicate gateway requests across services. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
982 B
C#
33 lines
982 B
C#
namespace CMSMicroservice.Application.Common.Interfaces;
|
|
|
|
/// <summary>
|
|
/// Per-scope in-process mutex for payment flows (initiate / verify).
|
|
/// Prevents the same user from running duplicate gateway operations concurrently.
|
|
/// </summary>
|
|
public interface IUserPaymentLock
|
|
{
|
|
Task<T> ExecuteAsync<T>(
|
|
string scope,
|
|
PaymentLockStrategy strategy,
|
|
Func<CancellationToken, Task<T>> action,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
Task ExecuteAsync(
|
|
string scope,
|
|
PaymentLockStrategy strategy,
|
|
Func<CancellationToken, Task> action,
|
|
CancellationToken cancellationToken = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// How to behave when the payment lock is already held.
|
|
/// </summary>
|
|
public enum PaymentLockStrategy
|
|
{
|
|
/// <summary>Wait up to the configured timeout (callback / verify paths).</summary>
|
|
WaitForRelease,
|
|
|
|
/// <summary>Reject immediately (initiate / double-click paths).</summary>
|
|
FailFast
|
|
}
|