Exemple #1
0
 public BootstrapSetup WithActorRefProvider(ProviderSelection name)
 {
     return(new BootstrapSetup(Config, name));
 }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Settings" /> class.
        /// </summary>
        /// <param name="system">The system.</param>
        /// <param name="config">The configuration.</param>
        /// <param name="setup">The setup class used to help bootstrap the <see cref="ActorSystem"/></param>
        /// <exception cref="ConfigurationException">
        /// This exception is thrown if the 'akka.actor.provider' configuration item is not a valid type name or a valid actor ref provider.
        /// </exception>
        public Settings(ActorSystem system, Config config, ActorSystemSetup setup)
        {
            Setup           = setup;
            _userConfig     = config;
            _fallbackConfig = ConfigurationFactory.Default();
            RebuildConfig();

            System = system;

            var providerSelectionSetup = Setup.Get <BootstrapSetup>()
                                         .FlatSelect(_ => _.ActorRefProvider)
                                         .Select(_ => _.Fqn)
                                         .GetOrElse(Config.GetString("akka.actor.provider", null));

            ProviderSelectionType = ProviderSelection.GetProvider(providerSelectionSetup);

            ConfigVersion = Config.GetString("akka.version", null);
            ProviderClass = ProviderSelectionType.Fqn;
            HasCluster    = ProviderSelectionType.HasCluster;

            var providerType = Type.GetType(ProviderClass);

            if (providerType == null)
            {
                throw new ConfigurationException($"'akka.actor.provider' is not a valid type name : '{ProviderClass}'");
            }
            if (!typeof(IActorRefProvider).IsAssignableFrom(providerType))
            {
                throw new ConfigurationException($"'akka.actor.provider' is not a valid actor ref provider: '{ProviderClass}'");
            }

            SupervisorStrategyClass = Config.GetString("akka.actor.guardian-supervisor-strategy", null);

            AskTimeout           = Config.GetTimeSpan("akka.actor.ask-timeout", null, allowInfinite: true);
            CreationTimeout      = Config.GetTimeSpan("akka.actor.creation-timeout", null);
            UnstartedPushTimeout = Config.GetTimeSpan("akka.actor.unstarted-push-timeout", null);

            SerializeAllMessages = Config.GetBoolean("akka.actor.serialize-messages", false);
            SerializeAllCreators = Config.GetBoolean("akka.actor.serialize-creators", false);

            LogLevel           = Config.GetString("akka.loglevel", null);
            StdoutLogLevel     = Config.GetString("akka.stdout-loglevel", null);
            Loggers            = Config.GetStringList("akka.loggers", new string[] { });
            LoggersDispatcher  = Config.GetString("akka.loggers-dispatcher", null);
            LoggerStartTimeout = Config.GetTimeSpan("akka.logger-startup-timeout", null);
            LoggerAsyncStart   = Config.GetBoolean("akka.logger-async-start", false);

            //handled
            LogConfigOnStart = Config.GetBoolean("akka.log-config-on-start", false);
            LogDeadLetters   = 0;
            switch (Config.GetString("akka.log-dead-letters", null))
            {
            case "on":
            case "true":
            case "yes":
                LogDeadLetters = int.MaxValue;
                break;

            case "off":
            case "false":
            case "no":
                LogDeadLetters = 0;
                break;

            default:
                LogDeadLetters = Config.GetInt("akka.log-dead-letters", 0);
                break;
            }
            LogDeadLettersDuringShutdown = Config.GetBoolean("akka.log-dead-letters-during-shutdown", false);
            AddLoggingReceive            = Config.GetBoolean("akka.actor.debug.receive", false);
            DebugAutoReceive             = Config.GetBoolean("akka.actor.debug.autoreceive", false);
            DebugLifecycle              = Config.GetBoolean("akka.actor.debug.lifecycle", false);
            FsmDebugEvent               = Config.GetBoolean("akka.actor.debug.fsm", false);
            DebugEventStream            = Config.GetBoolean("akka.actor.debug.event-stream", false);
            DebugUnhandledMessage       = Config.GetBoolean("akka.actor.debug.unhandled", false);
            DebugRouterMisconfiguration = Config.GetBoolean("akka.actor.debug.router-misconfiguration", false);
            Home = Config.GetString("akka.home", "");
            DefaultVirtualNodesFactor = Config.GetInt("akka.actor.deployment.default.virtual-nodes-factor", 0);

            SchedulerClass           = Config.GetString("akka.scheduler.implementation", null);
            SchedulerShutdownTimeout = Config.GetTimeSpan("akka.scheduler.shutdown-timeout", null);

            CoordinatedShutdownTerminateActorSystem      = Config.GetBoolean("akka.coordinated-shutdown.terminate-actor-system");
            CoordinatedShutdownRunByActorSystemTerminate = Config.GetBoolean("akka.coordinated-shutdown.run-by-actor-system-terminate");

            if (CoordinatedShutdownRunByActorSystemTerminate && !CoordinatedShutdownTerminateActorSystem)
            {
                throw new ConfigurationException(
                          "akka.coordinated-shutdown.run-by-actor-system-terminate=on and " +
                          "akka.coordinated-shutdown.terminate-actor-system=off is not a supported configuration combination.");
            }
        }