예제 #1
0
        /// <summary>
        /// Creates a <see cref="Config"/> from an <see cref="IClusterConfig"/> object.
        /// Initialises the necessary remoting properties necessary for clustering as well.
        /// </summary>
        /// <param name="cfg">The <see cref="IClusterConfig"/></param>
        /// <returns><see cref="Config"/></returns>
        public static Config CreateClusterConfig(IClusterConfig cfg)
        {
            var seedNodes = string.Join(",", cfg.SeedNodePaths.Select(p => $"\"{p}\""));

            var roles = string.Join(",", cfg.Roles.Keys);

            var roleNumbers = string.Join(",", cfg.Roles.Select(kvp => $"{kvp.Key}.min-nr-of-members = {kvp.Value}"));

            var mainConfig = ConfigurationFactory
                             .ParseString(
                $@"
                    akka.cluster
                    {{
                        min-nr-of-members = {cfg.MinNodeNumberForUp},
                        seed-nodes = [{seedNodes}],
                        roles = [{roles}],
                        role
                        {{
                            {roleNumbers}
                        }}
                    }}")
                             .WithFallback(CreateRemotingConfig(cfg));

            return(mainConfig);
        }
예제 #2
0
 public GraphController(IGraphCache graph, IClusterConfig cluster)
 {
     _graph   = graph;
     _cluster = cluster;
 }
 public TimelineController(IClusterConfig cluster)
 {
     _cluster = cluster;
 }
 public LeaderFollowerDataSource(IClusterConfig cluster, IGraphData db)
 {
     _cluster = cluster;
     _db      = db;
 }
예제 #5
0
 public GraphCache(IClusterConfig config, IGraphData source)
 {
     _config   = config;
     _source   = new LeaderFollowerDataSource(config, source);
     _entities = new EntityCache(_source);
 }
예제 #6
0
 public ConsensusTransport(IClusterConfig config)
 {
     _config = config;
 }
예제 #7
0
 public static IGraphQuery Query(this IClusterConfig config) => new FailOverClient(config.ShuffledFollowers);
예제 #8
0
 public static IGraphLeader Leader(this IClusterConfig config) => Create <IGraphLeader>(config.CurrentLeader);
예제 #9
0
 public static IGraphDataWrite Write(this IClusterConfig config) => Create <IGraphDataWrite>(config.CurrentLeader);
예제 #10
0
 public static IGraphDataRead Read(this IClusterConfig config) => new FailOverClient(config.ShuffledFollowers);