示例#1
0
 public InteractionProcessor(IMessageSender sender, LifelineViewport viewport, NuclearStorage storage)
 {
     _sender        = sender;
     _viewport      = viewport;
     _storage       = storage;
     CurrentStoryId = new StoryId(Guid.Empty);
 }
 public Program(IMessageSender sender, IStoreEvents store, NuclearStorage storage)
 {
     this.sender = new SenderDecorator(sender);
     this.store = store;
     this.storage = storage;
     reader = new ConsoleReader();
 }
 public InteractionProcessor(IMessageSender sender, LifelineViewport viewport, NuclearStorage storage)
 {
     _sender = sender;
     _viewport = viewport;
     _storage = storage;
     CurrentStoryId = new StoryId(Guid.Empty);
 }
示例#4
0
 public MessageStorePublisher(MessageStore store, MessageSender sender, NuclearStorage storage, Predicate <StoreRecord> recordShouldBePublished)
 {
     _store   = store;
     _sender  = sender;
     _storage = storage;
     _recordShouldBePublished = recordShouldBePublished;
 }
 public MessageStorePublisher(MessageStore store, MessageSender sender, NuclearStorage storage, Predicate<StoreRecord> recordShouldBePublished)
 {
     _store = store;
     _sender = sender;
     _storage = storage;
     _recordShouldBePublished = recordShouldBePublished;
 }
 public Program(IMessageSender sender, IStoreEvents store, NuclearStorage storage)
 {
     this.sender  = new SenderDecorator(sender);
     this.store   = store;
     this.storage = storage;
     reader       = new ConsoleReader();
 }
        private static void InitializeProjections(NuclearStorage documentStore, IEnumerable <ProjectionInfo> generatedInfos, List <ProjectionInfo> readyForUse, List <ProjectionInfo> needRebuild)
        {
            needRebuild.ForEach(p => p.Initialize(documentStore));

            // for loaded projection initialize document store and projection
            // if there's a problem - switch to using correlating generated projection
            for (var i = 0; i < readyForUse.Count; i++)
            {
                var loadedProjectionInfo       = readyForUse[i];
                var relatedGeneratedProjection = generatedInfos.First(pi => pi == loadedProjectionInfo);
                try
                {
                    loadedProjectionInfo.Initialize(documentStore);
                }
                catch (Exception x)
                {
                    NetcoLogger.GetLogger(typeof(PartitionedProjectionsInfo)).Log().Error(x, "Error encountered while initializing projection info: {0}", loadedProjectionInfo.ProjectionName);
                    // switch to using generated projection info for this projection to force rebuild
                    readyForUse.RemoveAt(i);
                    i--;
                    relatedGeneratedProjection.Initialize(documentStore);
                    needRebuild.Add(relatedGeneratedProjection);
                }
            }
        }
示例#8
0
 public AggregateFactory(ITapeStorageFactory factory, IEnvelopeStreamer streamer, IQueueWriter writer, NuclearStorage storage, IIdentityGenerator generator)
 {
     _factory   = factory;
     _streamer  = streamer;
     _writer    = writer;
     _storage   = storage;
     _generator = generator;
 }
示例#9
0
 public ProjectionsRebuilder(string name, IDocumentStore targetContainer, MessageStore eventsStore, Func <IDocumentStore, IEnumerable <object> > projectors)
 {
     this._name            = name;
     this._targetContainer = targetContainer;
     this._eventsStore     = eventsStore;
     this._projectors      = projectors;
     this._storage         = new NuclearStorage(targetContainer);
 }
示例#10
0
 public MessageStorePublisher(string name, MessageStore store, MessageSender sender, NuclearStorage storage, Predicate <StoreRecord> recordShouldBePublished, int waitOnNoWorkInMilliseconds = 500)
 {
     _name    = name;
     _store   = store;
     _sender  = sender;
     _storage = storage;
     _recordShouldBePublished    = recordShouldBePublished;
     _waitOnNoWorkInMilliseconds = waitOnNoWorkInMilliseconds;
 }
示例#11
0
        protected static void SmartFailing(FailingMessage message, NuclearStorage storage)
        {
            var status = storage.GetSingletonOrNew <int>();

            if (status < message.FailXTimes)
            {
                storage.AddOrUpdateSingleton(() => 1, i => i + 1);
                throw new InvalidOperationException("Failure requested");
            }
        }
示例#12
0
        public void Initialize(NuclearStorage storage)
        {
            Condition.Requires(storage, "storage").IsNotNull();
            if (this._checkpoint == null)
            {
                this._checkpoint = storage.GetEntityOrThrow <ProjectionCheckpoint>(this.ProjectionName);
            }

            this._store = storage;
        }
示例#13
0
 static void Consume(CreateCustomer cmd, NuclearStorage storage, SimpleMessageSender sender)
 {
     var customer = new Customer(cmd.CustomerId, cmd.CustomerName);
     storage.AddEntity(customer.Id, customer);
     sender.SendOne(new CustomerCreated
         {
             CustomerId = cmd.CustomerId,
             CustomerName = cmd.CustomerName
         });
 }
        public void Init()
        {
            this._storeDictionary = new ConcurrentDictionary <string, ConcurrentDictionary <string, byte[]> >();
            this._token           = new CancellationToken();
            this._documentStorage = new MemoryDocumentStore(this._storeDictionary, new DocumentStrategy());
            this._storage         = new NuclearStorage(this._documentStorage);

            this._eventStore = new MessageStore(new MemoryAppendOnlyStore(), new DataSerializer(new List <Type> {
                typeof(TestEvent), typeof(OnEvent), typeof(OffEvent)
            }));
        }
示例#15
0
        static void Consume(CreateCustomer cmd, NuclearStorage storage, SimpleMessageSender sender)
        {
            var customer = new Customer(cmd.CustomerId, cmd.CustomerName);

            storage.AddEntity(customer.Id, customer);
            sender.SendOne(new CustomerCreated
            {
                CustomerId   = cmd.CustomerId,
                CustomerName = cmd.CustomerName
            });
        }
示例#16
0
        public async Task ResetUnitialized(IDocumentStore documentStore)
        {
            Condition.WithExceptionOnFailure <InvalidOperationException>().Requires(this._store, "_store").IsNull("ProjectionInfo is initialized, but is being reset with different document store");

            var storage = new NuclearStorage(documentStore);
            await storage.TryDeleteEntityAsync <ProjectionCheckpoint>(this.ProjectionName);

            await Task.WhenAll(this.ViewBuckets.Select(documentStore.ResetAsync));

            this._checkpoint = new ProjectionCheckpoint();
        }
        public static IEnumerable<object> ApplicationServices(IDocumentStore docs, IEventStore store)
        {
            var storage = new NuclearStorage(docs);
            var id = new DomainIdentityGenerator(storage);
            var unique = new UserIndexService(storage);
            var passwords = new PasswordGenerator();

            yield return new UserApplicationService(store);
            yield return new SecurityApplicationService(store, id, passwords, unique);
            yield return new RegistrationApplicationService(store, id, unique, passwords);
            yield return id;
        }
示例#18
0
        public void Init()
        {
            this._storeMock = Substitute.For <IDocumentStore>();

            ProjectionCheckpoint chetkpointOut;

            this._storeMock.GetReader <object, ProjectionCheckpoint>().TryGet(Arg.Any <object>(), out chetkpointOut).Returns(x =>
            {
                x[1] = new ProjectionCheckpoint();
                return(true);
            });
            this._storage = new NuclearStorage(this._storeMock);
        }
        protected static void Consume(Act message, NuclearStorage storage)
        {
            new TransactionTester
                {
                    OnCommit = () =>
                        {
                            var singleton = storage.AddOrUpdateSingleton(() => 1, i => i + 1);
                            Trace.WriteLine("Commit kicked " + singleton);
                        }
                };

            if (message.Fail)
                throw new InvalidOperationException("Fail requested");
        }
示例#20
0
        public static IEnumerable <object> ApplicationServices(IDocumentStore docs, IEventStore store)
        {
            var storage   = new NuclearStorage(docs);
            var id        = new DomainIdentityGenerator(storage);
            var unique    = new UserIndexService(storage);
            var passwords = new PasswordGenerator();


            yield return(new UserApplicationService(store));

            yield return(new SecurityApplicationService(store, id, passwords, unique));

            yield return(new RegistrationApplicationService(store, id, unique, passwords));

            yield return(id);
        }
        protected static void Consume(Act message, NuclearStorage storage)
        {
            new TransactionTester
            {
                OnCommit = () =>
                {
                    var singleton = storage.AddOrUpdateSingleton(() => 1, i => i + 1);
                    Trace.WriteLine("Commit kicked " + singleton);
                }
            };

            if (message.Fail)
            {
                throw new InvalidOperationException("Fail requested");
            }
        }
        public void SetUp()
        {
            _storeRecords = new List<StoreRecord>();
            _serializer = new TestMessageSerializer(new[] { typeof(SerializerTest1), typeof(SerializerTest2), typeof(string) });
            _path = Path.Combine(Path.GetTempPath(), "MessageStorePublisher", Guid.NewGuid().ToString());
            _appendOnlyStore = new FileAppendOnlyStore(new DirectoryInfo(_path));
            _appendOnlyStore.Initialize();
            _store = new MessageStore(_appendOnlyStore, _serializer);
            var streamer = new EnvelopeStreamer(_serializer);
            var queueWriter = new TestQueueWriter();
            _sender = new MessageSender(streamer, queueWriter);
            var store = new FileDocumentStore(Path.Combine(_path, "lokad-cqrs-test"), new DocumentStrategy());
            _nuclearStorage = new NuclearStorage(store);

            _publisher = new MessageStorePublisher(_store, _sender, _nuclearStorage, DoWePublishThisRecord);
        }
示例#23
0
        public void SetUp()
        {
            _storeRecords         = new List <StoreRecord>();
            this._serializer      = new TestMessageSerializer(new[] { typeof(SerializerTest1), typeof(SerializerTest2), typeof(string) });
            this._path            = Path.Combine(Path.GetTempPath(), "MessageStorePublisher", Guid.NewGuid().ToString());
            this._appendOnlyStore = new FileAppendOnlyStore(new DirectoryInfo(this._path));
            this._appendOnlyStore.Initialize();
            this._store = new MessageStore(this._appendOnlyStore, this._serializer);
            var streamer    = new EnvelopeStreamer(this._serializer);
            var queueWriter = new TestQueueWriter();

            this._sender = new MessageSender(streamer, queueWriter);
            var store = new FileDocumentStore(Path.Combine(this._path, "lokad-cqrs-test"), new DocumentStrategy());

            this._nuclearStorage = new NuclearStorage(store);

            this._publisher = new MessageStorePublisher("test-tape", this._store, this._sender, this._nuclearStorage, DoWePublishThisRecord);
        }
示例#24
0
        void VerifyNonAtomic(NuclearStorage storage)
        {
            storage.AddOrUpdateEntity(1, new Entity());
            storage.GetEntity<Entity>(1);
            storage.UpdateEntity<Entity>(1, e => e.Do());
            storage.TryDeleteEntity<Entity>(1);

            storage.AddOrUpdateSingleton(() => new Entity(), e => e.Do());
            storage.UpdateSingletonEnforcingNew<Entity>(e => e.Do());
            storage.GetSingleton<Entity>();
            storage.TryDeleteSingleton<Entity>();
            storage.UpdateSingleton<Entity>(e => e.Do());

            //storage.UpdateOrAddEntity<Entity>(1, e => e.Do());
            //storage.TryDelete<Entity>(1);

            //storage.SaveSingleton(new Entity());
            //storage.GetSingleton<Entity>();
            //storage.UpdateSingleton<Entity>(e => e.Do());
            //storage.TryDeleteSingleton<Entity>();
        }
示例#25
0
 public Handler(NuclearStorage storage)
 {
     _storage = storage;
 }
 private static void AssertContents(NuclearStorage setup)
 {
     Assert.AreEqual("test", setup.GetEntity<string>(1).Value);
     Assert.AreEqual(1, setup.GetSingleton<int>().Value);
 }
 protected static void SmartFailing(FailingMessage message, NuclearStorage storage)
 {
     var status = storage.GetSingletonOrNew<int>();
     if (status < message.FailXTimes)
     {
         storage.AddOrUpdateSingleton(() => 1, i => i + 1);
         throw new InvalidOperationException("Failure requested");
     }
 }
        public static void Rebuild(IDocumentStore targetContainer, ITapeStream stream)
        {
            var strategy = targetContainer.Strategy;
            var memory   = new MemoryStorageConfig();

            var memoryContainer = memory.CreateNuclear(strategy).Container;
            var tracked         = new ProjectionInspectingContainer(memoryContainer);

            var projections = new List <object>();

            projections.AddRange(DomainBoundedContext.Projections(tracked));
            projections.AddRange(ClientBoundedContext.Projections(tracked));
            //projections.AddRange(ApiOpsBoundedContext.Projections(tracked));

            if (tracked.Buckets.Count != projections.Count())
            {
                throw new InvalidOperationException("Count mismatch");
            }

            var storage = new NuclearStorage(targetContainer);
            var hashes  = storage.GetSingletonOrNew <ProjectionHash>().Entries;

            var memoryProjections = projections.Select((projection, i) =>
            {
                var bucketName = tracked.Buckets[i];
                var viewType   = tracked.Views[i];

                var projectionHash = GetClassHash(projection.GetType()) + "\r\n" + GetClassHash(viewType);

                bool needsRebuild = !hashes.ContainsKey(bucketName) || hashes[bucketName] != projectionHash;
                return(new
                {
                    bucketName,
                    projection,
                    hash = projectionHash,
                    needsRebuild
                });
            }).ToArray();

            foreach (var memoryProjection in memoryProjections)
            {
                if (memoryProjection.needsRebuild)
                {
                    SystemObserver.Notify("[warn] {0} needs rebuild", memoryProjection.bucketName);
                }
                else
                {
                    SystemObserver.Notify("[good] {0} is up-to-date", memoryProjection.bucketName);
                }
            }


            var needRebuild = memoryProjections.Where(x => x.needsRebuild).ToArray();

            if (needRebuild.Length == 0)
            {
                return;
            }



            var watch = Stopwatch.StartNew();

            var wire = new RedirectToDynamicEvent();

            needRebuild.ForEach(x => wire.WireToWhen(x.projection));


            var handlersWatch = Stopwatch.StartNew();

            Observe(stream, wire);
            var timeTotal      = watch.Elapsed.TotalSeconds;
            var handlerTicks   = handlersWatch.ElapsedTicks;
            var timeInHandlers = Math.Round(TimeSpan.FromTicks(handlerTicks).TotalSeconds, 1);

            Console.WriteLine("Total Elapsed: {0}sec ({1}sec in handlers)", Math.Round(timeTotal, 0), timeInHandlers);


            // delete projections that were rebuilt
            var bucketNames = needRebuild.Select(x => x.bucketName).ToArray();

            foreach (var name in bucketNames)
            {
                targetContainer.Reset(name);

                var contents = memoryContainer.EnumerateContents(name);
                targetContainer.WriteContents(name, contents);
            }

            var allBuckets = new HashSet <string>(memoryProjections.Select(p => p.bucketName));
            var obsolete   = hashes.Keys.Where(s => !allBuckets.Contains(s)).ToArray();

            foreach (var name in obsolete)
            {
                SystemObserver.Notify("[warn] {0} is obsolete", name);
                targetContainer.Reset(name);
            }
            storage.UpdateSingletonEnforcingNew <ProjectionHash>(x =>
            {
                x.Entries.Clear();

                foreach (var prj in memoryProjections)
                {
                    x.Entries[prj.bucketName] = prj.hash;
                }
            });
        }
示例#29
0
 public UserIndexService(NuclearStorage storage)
 {
     _storage = storage;
 }
示例#30
0
 public AccountHandler(Func <Definitions.Define.MyContext> context, AccountAggregateRepository repository, NuclearStorage storage)
 {
     _context    = context;
     _storage    = storage;
     _repository = repository;
 }
示例#31
0
 public IdentityGenerator(NuclearStorage storage)
 {
     _storage = storage;
 }
示例#32
0
 public ViewHandler(NuclearStorage storage, Func <MyMessageContext> contextFactory)
 {
     this.storage        = storage;
     this.contextFactory = contextFactory;
 }
示例#33
0
 public PubSubRouter(NuclearStorage storage, IQueueWriterFactory queueFactory, IEnvelopeStreamer streamer)
 {
     _storage = storage;
     _queueFactory = queueFactory;
     _streamer = streamer;
 }
 public UserIndexService(NuclearStorage storage)
 {
     _storage = storage;
 }
示例#35
0
        public Container Build()
        {
            var appendOnlyStore = CreateTapes(TapesContainer);
            var messageStore    = new MessageStore(appendOnlyStore, Streamer.MessageSerializer);

            var toCommandRouter      = new MessageSender(Streamer, CreateQueueWriter(RouterQueue));
            var toFunctionalRecorder = new MessageSender(Streamer, CreateQueueWriter(FunctionalRecorderQueue));
            var toEventHandlers      = new MessageSender(Streamer, CreateQueueWriter(EventProcessingQueue));

            var sender = new TypedMessageSender(toCommandRouter, toFunctionalRecorder);

            var store = new EventStore(messageStore);

            var quarantine = new EnvelopeQuarantine(Streamer, sender, Streaming.GetContainer(ErrorsContainer));

            var builder = new CqrsEngineBuilder(Streamer, quarantine);

            var events   = new RedirectToDynamicEvent();
            var commands = new RedirectToCommand();
            var funcs    = new RedirectToCommand();


            builder.Handle(CreateInbox(EventProcessingQueue), aem => CallHandlers(events, aem), "watch");
            builder.Handle(CreateInbox(AggregateHandlerQueue), aem => CallHandlers(commands, aem));
            builder.Handle(CreateInbox(RouterQueue), MakeRouter(messageStore), "watch");
            // multiple service queues
            _serviceQueues.ForEach(s => builder.Handle(CreateInbox(s), aem => CallHandlers(funcs, aem)));

            builder.Handle(CreateInbox(FunctionalRecorderQueue), aem => RecordFunctionalEvent(aem, messageStore));
            var viewDocs  = CreateDocs(ViewStrategy);
            var stateDocs = new NuclearStorage(CreateDocs(DocStrategy));



            var vector = new DomainIdentityGenerator(stateDocs);
            //var ops = new StreamOps(Streaming);
            var projections = new ProjectionsConsumingOneBoundedContext();

            // Domain Bounded Context
            DomainBoundedContext.EntityApplicationServices(viewDocs, store, vector).ForEach(commands.WireToWhen);
            DomainBoundedContext.FuncApplicationServices().ForEach(funcs.WireToWhen);
            DomainBoundedContext.Ports(sender).ForEach(events.WireToWhen);
            DomainBoundedContext.Tasks(sender, viewDocs, true).ForEach(builder.AddTask);
            projections.RegisterFactory(DomainBoundedContext.Projections);

            // Client Bounded Context
            projections.RegisterFactory(ClientBoundedContext.Projections);

            // wire all projections
            projections.BuildFor(viewDocs).ForEach(events.WireToWhen);

            // wire in event store publisher
            var publisher = new MessageStorePublisher(messageStore, toEventHandlers, stateDocs, DoWePublishThisRecord);

            builder.AddTask(c => Task.Factory.StartNew(() => publisher.Run(c)));

            return(new Container
            {
                Builder = builder,
                Setup = this,
                SendToCommandRouter = toCommandRouter,
                MessageStore = messageStore,
                ProjectionFactories = projections,
                ViewDocs = viewDocs,
                Publisher = publisher,
                AppendOnlyStore = appendOnlyStore
            });
        }
 protected static void HandleNuclear(NuclearMessage msg, SimpleMessageSender sender, NuclearStorage storage)
 {
     var count = storage.AddOrUpdateSingleton(() => 1, i => i + 1);
     if (count >= 2)
     {
         sender.SendBatch(new object[] {}, e => e.AddString("ok"));
         return;
     }
     sender.SendOne(new NuclearMessage());
 }
 public DomainIdentityGenerator(NuclearStorage storage)
 {
     _storage = storage;
 }
示例#38
0
        public static void Rebuild(CancellationToken token, IDocumentStore targetContainer, MessageStore stream, Func <IDocumentStore, IEnumerable <object> > projectors)
        {
            var strategy = targetContainer.Strategy;
            var memory   = new MemoryStorageConfig();

            var memoryContainer = memory.CreateNuclear(strategy).Container;
            var tracked         = new ProjectionInspectingStore(memoryContainer);

            var projections = new List <object>();

            projections.AddRange(projectors(tracked));

            if (tracked.Projections.Count != projections.Count())
            {
                throw new InvalidOperationException("Count mismatch");
            }
            tracked.ValidateSanity();

            var storage         = new NuclearStorage(targetContainer);
            var persistedHashes = new Dictionary <string, string>();
            var name            = "domain";

            storage.GetEntity <ProjectionHash>(name).IfValue(v => persistedHashes = v.BucketHashes);

            var activeMemoryProjections = projections.Select((projection, i) =>
            {
                var proj       = tracked.Projections[i];
                var bucketName = proj.StoreBucket;
                var viewType   = proj.EntityType;

                var projectionHash =
                    "Global change on 2012-08-24\r\n" +
                    GetClassHash(projection.GetType()) +
                    "\r\n " + GetClassHash(viewType) + "\r\n" + GetClassHash(strategy.GetType());

                bool needsRebuild = !persistedHashes.ContainsKey(bucketName) || persistedHashes[bucketName] != projectionHash;
                return(new
                {
                    bucketName,
                    projection,
                    hash = projectionHash,
                    needsRebuild
                });
            }).ToArray();

            foreach (var memoryProjection in activeMemoryProjections)
            {
                if (memoryProjection.needsRebuild)
                {
                    SystemObserver.Notify("[warn] {0} needs rebuild", memoryProjection.bucketName);
                }
                else
                {
                    SystemObserver.Notify("[good] {0} is up-to-date", memoryProjection.bucketName);
                }
            }


            var needRebuild = activeMemoryProjections.Where(x => x.needsRebuild).ToArray();

            if (needRebuild.Length == 0)
            {
                return;
            }


            var watch = Stopwatch.StartNew();

            var wire = new RedirectToDynamicEvent();

            needRebuild.ForEach(x => wire.WireToWhen(x.projection));


            var handlersWatch = Stopwatch.StartNew();



            ObserveWhileCan(stream.EnumerateAllItems(0, int.MaxValue), wire, token);

            if (token.IsCancellationRequested)
            {
                SystemObserver.Notify("[warn] Aborting projections before anything was changed");
                return;
            }

            var timeTotal      = watch.Elapsed.TotalSeconds;
            var handlerTicks   = handlersWatch.ElapsedTicks;
            var timeInHandlers = Math.Round(TimeSpan.FromTicks(handlerTicks).TotalSeconds, 1);

            SystemObserver.Notify("Total Elapsed: {0}sec ({1}sec in handlers)", Math.Round(timeTotal, 0), timeInHandlers);


            // update projections that need rebuild
            foreach (var b in needRebuild)
            {
                // server might shut down the process soon anyway, but we'll be
                // in partially consistent mode (not all projections updated)
                // so at least we blow up between projection buckets
                token.ThrowIfCancellationRequested();

                var bucketName = b.bucketName;
                var bucketHash = b.hash;

                // wipe contents
                targetContainer.Reset(bucketName);
                // write new versions
                var contents = memoryContainer.EnumerateContents(bucketName);
                targetContainer.WriteContents(bucketName, contents);

                // update hash
                storage.UpdateEntityEnforcingNew <ProjectionHash>(name, x =>
                {
                    x.BucketHashes[bucketName] = bucketHash;
                });

                SystemObserver.Notify("[good] Updated View bucket {0}.{1}", name, bucketName);
            }

            // Clean up obsolete views
            var allBuckets      = new HashSet <string>(activeMemoryProjections.Select(p => p.bucketName));
            var obsoleteBuckets = persistedHashes.Where(s => !allBuckets.Contains(s.Key)).ToArray();

            foreach (var hash in obsoleteBuckets)
            {
                // quit at this stage without any bad side effects
                if (token.IsCancellationRequested)
                {
                    return;
                }

                var bucketName = hash.Key;
                SystemObserver.Notify("[warn] {0} is obsolete", bucketName);
                targetContainer.Reset(bucketName);

                storage.UpdateEntityEnforcingNew <ProjectionHash>(name, x => x.BucketHashes.Remove(bucketName));

                SystemObserver.Notify("[good] Cleaned up obsolete view bucket {0}.{1}", name, bucketName);
            }
        }
示例#39
0
 public WebEndpoint(NuclearStorage store, IEnvelopeStreamer streamer, IQueueWriter writer)
 {
     _store    = store;
     _streamer = streamer;
     _writer   = writer;
 }
示例#40
0
 public void Init()
 {
     this._storeMock = Substitute.For <IDocumentStore>();
     this._storage   = new NuclearStorage(this._storeMock);
 }
 public CustomerHandler(NuclearStorage storage, IMessageSender sender)
 {
     _storage = storage;
     _sender  = sender;
 }
示例#42
0
 public InteractionContext(InteractionRequest request, NuclearStorage storage, InteractionResponse response)
 {
     Request = request;
     Storage = storage;
     Response = response;
 }
示例#43
0
 public PubSubRouter(NuclearStorage storage, IQueueWriterFactory queueFactory, IEnvelopeStreamer streamer)
 {
     _storage      = storage;
     _queueFactory = queueFactory;
     _streamer     = streamer;
 }
 public InteractionContext(InteractionRequest request, NuclearStorage storage, InteractionResponse response)
 {
     Request  = request;
     Storage  = storage;
     Response = response;
 }
        public static PartitionedProjectionsInfo Partition(IEnumerable <ProjectionInfo> loadedInfos, IEnumerable <ProjectionInfo> generatedInfos, NuclearStorage documentStore)
        {
            var readyForUse = loadedInfos.Where(li => generatedInfos.Any(gi => li == gi)).ToList();
            var needRebuild = generatedInfos.Where(gi => readyForUse.All(r => r != gi)).ToList();

            // filter out all ready for use and any that needs to be rebuilt (by name, since hash is going to be different)
            var obsolete = loadedInfos.Where(li => readyForUse.All(r => r != li) && needRebuild.Select(r => r.ProjectionName).All(r => !r.Equals(li.ProjectionName, StringComparison.OrdinalIgnoreCase))).ToList();

            InitializeProjections(documentStore, generatedInfos, readyForUse, needRebuild);
            ValidateSanity(readyForUse, needRebuild, obsolete);

            return(new PartitionedProjectionsInfo(readyForUse, obsolete, needRebuild));
        }