Beispiel #1
0
        void InitializeServices(EvenStartInfo startInfo)
        {
            var serializer   = startInfo.Serializer;
            var store        = startInfo.Store;
            var options      = startInfo.Options;
            var registry     = new EventRegistry();
            var eventFactory = new PersistedEventFactory(registry, serializer);

            foreach (var kvp in startInfo.EventTypes)
            {
                registry.Register(kvp.Key, kvp.Value);
            }

            // initialize reader
            var readerProps = EventStoreReader.CreateProps(store, eventFactory, options);

            _reader = Context.ActorOf(readerProps, "reader");

            // initialize dispatcher
            var dispatcherProps = EventDispatcher.CreateProps(_reader, options);

            _dispatcher = Context.ActorOf(dispatcherProps, "dispatcher");

            // initialize writer
            var writerProps = EventStoreWriter.CreateProps(store, serializer, _dispatcher, options);

            _writer = Context.ActorOf(writerProps, "writer");

            // initialize event processor supervisor
            var eventProcessorsProps = EventProcessorSupervisor.CreateProps(options);

            _eventProcessors = Context.ActorOf(eventProcessorsProps, "eventprocessors");

            // initialize projection streams supervisor
            var projectionStreamsProps = ProjectionStreamSupervisor.CreateProps(_reader, _writer, options);

            _projectionStreams = Context.ActorOf(projectionStreamsProps, "projectionstreams");

            // initialize projections supervisor
            var projectionProps = ProjectionSupervisor.CreateProps(_projectionStreams, options);

            _projections = Context.ActorOf(projectionProps, "projections");

            // initialize command processors supervisor
            var commandProcessorsProps = CommandProcessorSupervisor.CreateProps(_writer, options);

            _commandProcessors = Context.ActorOf(commandProcessorsProps, "commandprocessors");

            // initialize aggregates
            var aggregatesProps = AggregateSupervisor.CreateProps(_reader, _writer, options);

            _aggregates = Context.ActorOf(aggregatesProps, "aggregates");
        }
Beispiel #2
0
        public async Task <EvenGateway> Start(string name = null)
        {
            var options    = _options ?? new GlobalOptions();
            var store      = _store ?? new InMemoryStore();
            var serializer = _serializer ?? new DefaultSerializer();

            var startInfo = new EvenStartInfo(store, serializer, options);

            startInfo.Projections.AddRange(_projections);
            startInfo.EventProcessors.AddRange(_eventProcessors);

            var props   = EvenMaster.CreateProps(startInfo);
            var master  = _system.ActorOf(props, name);
            var timeout = TimeSpan.FromSeconds(5);

            var services = (EvenServices)await master.Ask(new GetEvenServices(), timeout);

            return(new EvenGateway(services, _system, options));
        }
Beispiel #3
0
        void InitializeServices(EvenStartInfo startInfo)
        {
            var serializer = startInfo.Serializer;
            var store = startInfo.Store;
            var options = startInfo.Options;
            var registry = new EventRegistry();
            var eventFactory = new PersistedEventFactory(registry, serializer);

            foreach (var kvp in startInfo.EventTypes)
                registry.Register(kvp.Key, kvp.Value);

            // initialize reader
            var readerProps = EventStoreReader.CreateProps(store, eventFactory, options);
            _reader = Context.ActorOf(readerProps, "reader");

            // initialize dispatcher
            var dispatcherProps = EventDispatcher.CreateProps(_reader, options);
            _dispatcher = Context.ActorOf(dispatcherProps, "dispatcher");

            // initialize writer
            var writerProps = EventStoreWriter.CreateProps(store, serializer, _dispatcher, options);
            _writer = Context.ActorOf(writerProps, "writer");

            // initialize event processor supervisor
            var eventProcessorsProps = EventProcessorSupervisor.CreateProps(options);
            _eventProcessors = Context.ActorOf(eventProcessorsProps, "eventprocessors");

            // initialize projection streams supervisor
            var projectionStreamsProps = ProjectionStreamSupervisor.CreateProps(_reader, _writer, options);
            _projectionStreams = Context.ActorOf(projectionStreamsProps, "projectionstreams");

            // initialize projections supervisor
            var projectionProps = ProjectionSupervisor.CreateProps(_projectionStreams, options);
            _projections = Context.ActorOf(projectionProps, "projections");

            // initialize command processors supervisor
            var commandProcessorsProps = CommandProcessorSupervisor.CreateProps(_writer, options);
            _commandProcessors = Context.ActorOf(commandProcessorsProps, "commandprocessors");

            // initialize aggregates
            var aggregatesProps = AggregateSupervisor.CreateProps(_reader, _writer, options);
            _aggregates = Context.ActorOf(aggregatesProps, "aggregates");
        }
Beispiel #4
0
 public EvenMaster(EvenStartInfo startInfo)
 {
     Self.Tell(startInfo);
     InitializingServices();
 }
Beispiel #5
0
        public static Props CreateProps(EvenStartInfo startInfo)
        {
            Argument.RequiresNotNull(startInfo, nameof(startInfo));

            return Props.Create<EvenMaster>(startInfo);
        }
Beispiel #6
0
 public EvenMaster(EvenStartInfo startInfo)
 {
     Self.Tell(startInfo);
     InitializingServices();
 }
Beispiel #7
0
        public static Props CreateProps(EvenStartInfo startInfo)
        {
            Argument.RequiresNotNull(startInfo, nameof(startInfo));

            return(Props.Create <EvenMaster>(startInfo));
        }