public EnforceExclusiveSagaAccessIncomingStep(IExclusiveAccessLock lockHandler, int maxLockBuckets, string lockPrefix, CancellationToken cancellationToken, TimeSpan?lockSleepMinDelay = null, TimeSpan?lockSleepMaxDelay = null) : base(maxLockBuckets, cancellationToken) { _lockHandler = lockHandler; _lockPrefix = lockPrefix; _lockSleepMinDelay = lockSleepMinDelay ?? TimeSpan.FromMilliseconds(10); _lockSleepMaxDelay = lockSleepMaxDelay ?? TimeSpan.FromMilliseconds(20); _random = new Random(DateTime.Now.GetHashCode()); }
/// <summary> /// Forces exclusive access using a lockhandler defined by <see cref="IExclusiveAccessLock"/> /// </summary> public static void EnforceExclusiveAccess(this StandardConfigurer <ISagaStorage> configurer, IExclusiveAccessLock locker, string lockPrefix = null, int maxLockBuckets = 1000) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } configurer .OtherService <IPipeline>() .Decorate(c => { var pipeline = c.Get <IPipeline>(); var cancellationToken = c.Get <CancellationToken>(); var step = new EnforceExclusiveSagaAccessIncomingStep(locker, maxLockBuckets, lockPrefix ?? "sagalock_", cancellationToken); return(new PipelineStepInjector(pipeline) .OnReceive(step, PipelineRelativePosition.Before, typeof(LoadSagaDataStep))); }); }