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)));
        }
 public static ReducerResult <TData> Sucess <TData>(MutatingContext <TData> data) => new(data, null);
 protected override void SetDataInternal(MutatingContext <ApplicationList> data)
 => ApplicationList = data.Data;
 protected override MutatingContext <ApplicationList> GetDataInternal()
 => MutatingContext <ApplicationList> .New(ApplicationList);
Example #6
0
 protected override void SetDataInternal(MutatingContext <ProjectFile> data)
 => Interlocked.Exchange(ref _projectFile, data.Data);
Example #7
0
 protected override MutatingContext <ProjectFile> GetDataInternal()
 => MutatingContext <ProjectFile> .New(_projectFile);
Example #8
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 #9
0
 public static MutatingContext <ClusterConfiguration> AddSeedUrl(MutatingContext <ClusterConfiguration> state, AddSeedUrlAction action)
 => state.Data.Seeds.Contains(action.Url) ? state : state.WithChange(new AddSeedUrlEvent(action.Url));
 protected override void SetDataInternal(MutatingContext <ProjectFile> data)
 {
     _projectFile.OnNext(data.Data);
 }