Beispiel #1
0
        public ShardInstance(ShardSetsBase <TConfiguration> parent, short shardId, IShardConnectionConfiguration shardConnection)
        {
            this.ShardId = shardId;
            var readConnection  = shardConnection.ReadConnectionInternal;
            var writeConnection = shardConnection.WriteConnectionInternal;

            if (shardConnection.ReadConnectionInternal is null && !(shardConnection.WriteConnectionInternal is null))
            {
                readConnection = writeConnection;
            }
Beispiel #2
0
            public ShardSet(ShardSetsBase <TConfiguration> parent, IShardSetConnectionsConfiguration config)
            {
                var bdr = ImmutableDictionary.CreateBuilder <short, ShardInstance <TConfiguration> >();

                _defaultShardId = config.DefaultShardId;
                foreach (var shd in config.ShardsConfigInternal)
                {
                    if (shd is null)
                    {
                        throw new Exception($"A shard set’s connection configuration was not valid; the configuration provider returned null.");
                    }
                    var shardSetsConfig = config as DataConnectionConfigurationBase;
                    var shardConfig     = shd as DataConnectionConfigurationBase;
                    var readConfig      = config.ReadConfigInternal as DataConnectionConfigurationBase;
                    var writeConfig     = config.WriteConfigInternal as DataConnectionConfigurationBase;
                    shd.ReadConnectionInternal.SetAmbientConfiguration(parent._globalConfiguration, shardSetsConfig, readConfig, shardConfig);
                    shd.WriteConnectionInternal.SetAmbientConfiguration(parent._globalConfiguration, shardSetsConfig, writeConfig, shardConfig);
                    bdr.Add(shd.ShardId, new ShardInstance <TConfiguration>(parent, shd.ShardId, shd));
                }
                this.dtn       = bdr.ToImmutable();
                this.ReadAll   = new ShardSetReadAll(this);
                this.ReadFirst = new ShardSetReadFirst(this);
                this.Write     = new ShardSetWrite(this);
            }