Esempio n. 1
0
        public static Config BoostrapApplication(this Config c, AppBootstrapConfig appConfig)
        {
            var config = c;

            if (appConfig.NeedPersistence)
            {
                var mongoConnectionString = Environment.GetEnvironmentVariable("MONGO_CONNECTION_STR")?.Trim();
                if (string.IsNullOrEmpty(mongoConnectionString))
                {
                    Console.WriteLine("ERROR! MongoDb connection string not provided. Can't start.");
                    throw new ConfigurationException("ERROR! MongoDb connection string not provided. Can't start.");
                }
                else
                {
                    Console.WriteLine("Connecting to MongoDb at {0}", mongoConnectionString);
                }

                config = c.WithFallback(GetMongoHocon(mongoConnectionString));
            }

            config = config
                     .WithFallback(GetOpsConfig())
                     .WithFallback(TradeEventSerializer.Config)
                     .WithFallback(ClusterSharding.DefaultConfig())
                     .WithFallback(DistributedData.DistributedData.DefaultConfig()) // needed for DData sharding
                     .WithFallback(ClusterClientReceptionist.DefaultConfig())
                     .WithFallback(DistributedPubSub.DefaultConfig())
                     .BootstrapFromDocker();


#if PHOBOS
            return(config.BootstrapPhobos(appConfig));
#else
            if (!appConfig.NeedClustering)
            {
                return(ConfigurationFactory.ParseString("akka.actor.provider = remote").WithFallback(config));
            }


            return(config);
#endif
        }
Esempio n. 2
0
        public static Config BootstrapPhobos(this Config c, AppBootstrapConfig appConfig)
        {
            var enablePhobos = Environment.GetEnvironmentVariable(ENABLE_PHOBOS);

            if (!bool.TryParse(enablePhobos, out var phobosEnabled))
            {
                // don't turn on Phobos
                return(c);
            }
            else if (!phobosEnabled)
            {
                // don't turn on Phobos
                return(c);
            }

            var phobosConfig = GetPhobosConfig();

            var statsdUrl       = Environment.GetEnvironmentVariable(STATSD_URL);
            var statsDPort      = Environment.GetEnvironmentVariable(STATSD_PORT);
            var jaegerAgentHost = Environment.GetEnvironmentVariable(JAEGER_AGENT_HOST);

            if (!string.IsNullOrEmpty(statsdUrl) && int.TryParse(statsDPort, out var portNum))
            {
                phobosConfig = ConfigurationFactory.ParseString($"phobos.monitoring.statsd.endpoint=\"{statsdUrl}\"" +
                                                                Environment.NewLine +
                                                                $"phobos.monitoring.statsd.port={portNum}" +
                                                                Environment.NewLine +
                                                                $"phobos.tracing.jaeger.agent.host={jaegerAgentHost}")
                               .WithFallback(phobosConfig);
            }

            if (!appConfig.NeedClustering)
            {
                var config = ConfigurationFactory.ParseString(@"akka.actor.provider = ""Phobos.Actor.Remote.PhobosRemoteActorRefProvider, Phobos.Actor.Remote""");
                return(config.WithFallback(phobosConfig).WithFallback(c));
            }

            return(phobosConfig.WithFallback(c));
        }