Example #1
0
        internal ActorRuntime(ActorRuntimeOptions options, ILoggerFactory loggerFactory)
        {
            this.actorSettings = new ActorSettings();
            this.logger        = loggerFactory.CreateLogger(this.GetType());

            // Create ActorManagers, override existing entry if registered again.
            foreach (var actorServiceFunc in options.actorServicesFunc)
            {
                var actorServiceFactory = actorServiceFunc.Value ?? ((type) => new ActorService(type, loggerFactory));
                var actorService        = actorServiceFactory.Invoke(actorServiceFunc.Key);

                this.actorManagers[actorServiceFunc.Key.ActorTypeName] = new ActorManager(actorService, loggerFactory);
            }
        }
Example #2
0
        internal ActorRuntime(ActorRuntimeOptions options, ILoggerFactory loggerFactory, ActorActivatorFactory activatorFactory)
        {
            this.options          = options;
            this.logger           = loggerFactory.CreateLogger(this.GetType());
            this.activatorFactory = activatorFactory;

            // Loop through actor registrations and create the actor manager for each one.
            // We do this up front so that we can catch initialization errors early, and so
            // that access to state can have a simple threading model.
            //
            // Revisit this if actor initialization becomes a significant source of delay for large projects.
            foreach (var actor in options.Actors)
            {
                this.actorManagers[actor.Type.ActorTypeName] = new ActorManager(
                    actor,
                    actor.Activator ?? this.activatorFactory.CreateActivator(actor.Type),
                    loggerFactory);
            }
        }
Example #3
0
        internal ActorRuntime(ActorRuntimeOptions options, ILoggerFactory loggerFactory, ActorActivatorFactory activatorFactory, IActorProxyFactory proxyFactory)
        {
            this.options          = options;
            this.logger           = loggerFactory.CreateLogger(this.GetType());
            this.activatorFactory = activatorFactory;
            this.proxyFactory     = proxyFactory;

            // Loop through actor registrations and create the actor manager for each one.
            // We do this up front so that we can catch initialization errors early, and so
            // that access to state can have a simple threading model.
            //
            // Revisit this if actor initialization becomes a significant source of delay for large projects.
            foreach (var actor in options.Actors)
            {
                var daprInteractor = new DaprHttpInteractor(clientHandler: null, httpEndpoint: options.HttpEndpoint, apiToken: options.DaprApiToken, requestTimeout: null);
                this.actorManagers[actor.Type.ActorTypeName] = new ActorManager(
                    actor,
                    actor.Activator ?? this.activatorFactory.CreateActivator(actor.Type),
                    this.options.JsonSerializerOptions,
                    loggerFactory,
                    proxyFactory,
                    daprInteractor);
            }
        }