public static MutatingContext <ServicesConfigurationData> ApplyMongoUrl(MutatingContext <ServicesConfigurationData> state, ApplyMongoUrlAction action)
        {
            Log.Information("Update AppBase Configuration");

            const string snapshot = "akka.persistence.snapshot-store.plugin = \"akka.persistence.snapshot-store.mongodb\"";
            const string journal  = "akka.persistence.journal.plugin = \"akka.persistence.journal.mongodb\"";

            const string connectionSnapshot = "akka.persistence.snapshot-store.mongodb.connection-string = \"{0}\"";
            const string connectionJournal  = "akka.persistence.journal.mongodb.connection-string = \"{0}\"";

            var currentConfiguration = ConfigurationFactory.ParseString(state.Data.BaseConfiguration);

            var hasBase = currentConfiguration.HasPath("akka.persistence.journal.mongodb.connection-string ") ||
                          currentConfiguration.HasPath("akka.persistence.snapshot-store.mongodb.connection-string");

            if (!hasBase)
            {
                Log.Information("Apply Default Configuration");
                currentConfiguration = ConfigurationFactory.ParseString(Resources.BaseConfig).WithFallback(currentConfiguration);
            }

            var builder = new StringBuilder();

            builder
            .AppendLine(snapshot)
            .AppendLine(journal)
            .AppendFormat(connectionSnapshot, action.Url).AppendLine()
            .AppendFormat(connectionJournal, action.Url).AppendLine();

            currentConfiguration = ConfigurationFactory.ParseString(builder.ToString()).WithFallback(currentConfiguration);

            Log.Information("AppBase Configuration Updated");

            return(state.WithChange(new ConfigurationChangedEvent(currentConfiguration.ToString(true))));
        }
Example #2
0
        public static MutatingContext <ClusterConfiguration> TryJoinReducer(MutatingContext <ClusterConfiguration> state, TryJoinAction action)
        {
            var seeds = state.Data.Seeds;

            if (seeds.Count == 0)
            {
                seeds = seeds.Add(state.Data.SelfAddress);
            }

            return(state.WithChange(new TryJoinEvent(seeds)));
        }
Example #3
0
 public static MutatingContext <ClusterConfiguration> RemoveSeedUlr(MutatingContext <ClusterConfiguration> state, RemoveSeedUrlAction action)
 => !state.Data.Seeds.Contains(action.Url) ? state : state.WithChange(new RemoveSeedUrlEvent(action.Url, state.Data.Seeds.Count - 1));
Example #4
0
 public static MutatingContext <ClusterConfiguration> AddSeedUrl(MutatingContext <ClusterConfiguration> state, AddSeedUrlAction action)
 => state.Data.Seeds.Contains(action.Url) ? state : state.WithChange(new AddSeedUrlEvent(action.Url));