public RedisAggregateRootAtomicAction(IAggregateRootLock aggregateRootLock,
                                              IRevisionStore revisionStore,
                                              RedisAtomicActionOptions options)
        {
            if (ReferenceEquals(null, aggregateRootLock)) throw new ArgumentNullException(nameof(aggregateRootLock));
            if (ReferenceEquals(null, revisionStore)) throw new ArgumentNullException(nameof(revisionStore));
            if (ReferenceEquals(null, options)) throw new ArgumentNullException(nameof(options));

            this.aggregateRootLock = aggregateRootLock;
            this.revisionStore = revisionStore;
            this.options = options;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var endPoint1 = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1001);

            var endPoints = new[] { endPoint1 };

            var redlock = new RedisLockManager(endPoints);
            var aggregateRootLock = new RedisAggregateRootLock(redlock);
            var revisionStore = new RedisRevisionStore(endPoints);

            var options = new RedisAtomicActionOptions();
            options.LockTtl = TimeSpan.FromSeconds(1);
            options.ShorTtl = TimeSpan.FromSeconds(1);

            var atomicAction = new RedisAggregateRootAtomicAction(aggregateRootLock, revisionStore, options);
            var id = new HeadquarterId("e0846069-2730-4d3c-bc80-470d6a521d99", "elders");

            var result = atomicAction.Execute(id, 1, () => { });

            Console.WriteLine(result.IsSuccessful);
            Console.WriteLine(result.Value);
        }