public ShardedDb(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm, IMainShardDataProvider mainShardDataProvider, IConnectionProvider connectionProvider) { this._shardConfiguration = shardConfiguration; this._shardKeyAlgorithm = algorithm; this._mainShardDataProvider = mainShardDataProvider; this._connectionProvider = connectionProvider; subShardMap = new Dictionary <int, V>(); _shardMap = new Dictionary <string, int>(); _shards = new List <int>(); var connection = connectionProvider.GetMainConnectionString(); mainShardDataProvider.Initialize(connection); mainShardDataProvider.LoadShardMap(_shards, _shardMap); if (subShardMap.Count < shardConfiguration.ShardCount) { SetupShard(shardConfiguration.ShardCount - subShardMap.Count); } }
public SqlMainShardDataProvider(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm) { _shardConfiguration = shardConfiguration; _shardKeyAlgorithm = algorithm; }
public SqlDb(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm) : base(shardConfiguration, algorithm, new SqlMainShardDataProvider(shardConfiguration, algorithm), new SqlConnectionProvider()) { }
public InMemoryDB(ShardConfiguration shardConfiguration, IShardKeyAlgorithm algorithm) : base(shardConfiguration, algorithm, new InMemoryMainShardDataProvider(shardConfiguration, algorithm), new InMemoryConnectionProvider()) { }