Beispiel #1
0
        private ActorSystem CreateActorSystem(Config config, IActorSystemDependencyResolver dependencyResolver)
        {
            var actorSystem = ActorSystem.Create("actor-system", config);

            dependencyResolver.RegisterDependencyResolver(actorSystem);
            SqlitePersistence.Get(actorSystem);
            return(actorSystem);
        }
Beispiel #2
0
        public ActorSystemAccessor(IHostEnvironment env, IActorSystemDependencyResolver dependencyResolver, IOptionsMonitor <ActorSystemOptions> actorSystemOptions)
        {
            var options        = actorSystemOptions.CurrentValue;
            var configFileName = File.ReadAllText(Path.Combine(env.ContentRootPath, "config.hocon"));
            var config         = LoadConfiguration(configFileName);

            this.dependencyResolver = dependencyResolver;
            actorSystem             = CreateActorSystem(config, dependencyResolver);
            primaryCommandHandler   = CreatePrimaryCommandHandler(actorSystem, options);
            primaryEventHandler     = CreatePrimaryEventHandler(actorSystem, options);
            //TODO: here we assume only one Persistence Query will be needed throughout the application life cycle
            //If this is not the case, then we should not create it here. Instead, it should be created by a command handler actor and live in its scope.
            actorMaterializer = ConfigureEventHandling(actorSystem, primaryEventHandler, options);
        }