添加了一些简单的备注
This commit is contained in:
parent
d917259ac7
commit
7bcadfc100
|
@ -7,8 +7,8 @@
|
||||||
<RepositoryUrl>https://github.com/xuejmnet/sharding-core</RepositoryUrl>
|
<RepositoryUrl>https://github.com/xuejmnet/sharding-core</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<Company>xuejm</Company>
|
<Company>xuejm</Company>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>9.0</LangVersion>
|
||||||
<Description>easy sharding for efcore 2.x 3.x 5.x lib.</Description>
|
<Description>high performance lightweight solution for efcore sharding table and sharding database support read-write-separation </Description>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
|
@ -31,6 +31,7 @@ namespace ShardingCore.Core.VirtualRoutes.DataSourceRoutes.Abstractions
|
||||||
/// 是否启用路由解析编译缓存
|
/// 是否启用路由解析编译缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool EnableRouteParseCompileCache => false;
|
public virtual bool EnableRouteParseCompileCache => false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对表达式进行缓存编译默认永久缓存单个参数表达式,且不包含orElse只包含单个AndAlso或者没有AndAlso的,
|
/// 对表达式进行缓存编译默认永久缓存单个参数表达式,且不包含orElse只包含单个AndAlso或者没有AndAlso的,
|
||||||
/// 比如:<![CDATA[o.id==x]]>或者<![CDATA[o.id>x]]>,不会缓存<![CDATA[o=>id>x && o.id<y ]]>等一共大于、等于、小于、大于等于、小于等于(不等于编译成<![CDATA[t=>true]]>)缓存会存在的数量个数上限为
|
/// 比如:<![CDATA[o.id==x]]>或者<![CDATA[o.id>x]]>,不会缓存<![CDATA[o=>id>x && o.id<y ]]>等一共大于、等于、小于、大于等于、小于等于(不等于编译成<![CDATA[t=>true]]>)缓存会存在的数量个数上限为
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
/// 系统默认永久单表达式缓存
|
/// 系统默认永久单表达式缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parseWhere"></param>
|
/// <param name="parseWhere"></param>
|
||||||
/// <returns>返回null会走<see cref="CustomerCachingCompile"/>这个方法如果还是null就会调用<see cref="Compile"/>方法</returns>
|
/// <returns>返回null会走<see cref="CustomerCachingCompile"/>这个方法如果还是null就会调用<see cref="LambdaExpression.Compile()"/>方法</returns>
|
||||||
protected virtual Func<string, bool> DoCachingCompile(Expression<Func<string, bool>> parseWhere)
|
protected virtual Func<string, bool> DoCachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
{
|
||||||
var shouldCache = ShouldCache(parseWhere);
|
var shouldCache = ShouldCache(parseWhere);
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly DoOnlyOnce _doOnlyOnce = new DoOnlyOnce();
|
private readonly DoOnlyOnce _doOnlyOnce = new DoOnlyOnce();
|
||||||
public void Initialize(EntityMetadata entityMetadata)
|
public virtual void Initialize(EntityMetadata entityMetadata)
|
||||||
{
|
{
|
||||||
if (!_doOnlyOnce.IsUnDo())
|
if (!_doOnlyOnce.IsUnDo())
|
||||||
throw new ShardingCoreInvalidOperationException("already init");
|
throw new ShardingCoreInvalidOperationException("already init");
|
||||||
|
|
|
@ -96,6 +96,8 @@ namespace ShardingCore.DIExtensions
|
||||||
public bool? IgnoreCreateTableError { get; set; } = true;
|
public bool? IgnoreCreateTableError { get; set; } = true;
|
||||||
public int MaxQueryConnectionsLimit { get; set; } = Environment.ProcessorCount;
|
public int MaxQueryConnectionsLimit { get; set; } = Environment.ProcessorCount;
|
||||||
public ConnectionModeEnum ConnectionMode { get; set; } = ConnectionModeEnum.SYSTEM_AUTO;
|
public ConnectionModeEnum ConnectionMode { get; set; } = ConnectionModeEnum.SYSTEM_AUTO;
|
||||||
|
public bool? EnableTableRouteCompileCache { get; set; }
|
||||||
|
public bool? EnableDataSourceRouteCompileCache { get; set; }
|
||||||
|
|
||||||
private readonly ISet<Type> _createTableEntities = new HashSet<Type>();
|
private readonly ISet<Type> _createTableEntities = new HashSet<Type>();
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,14 @@ namespace ShardingCore
|
||||||
/// 连接数限制
|
/// 连接数限制
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConnectionModeEnum ConnectionMode { get; set; }
|
public ConnectionModeEnum ConnectionMode { get; set; }
|
||||||
|
///// <summary>
|
||||||
|
///// 是否启用表路由编译缓存
|
||||||
|
///// </summary>
|
||||||
|
//public bool? EnableTableRouteCompileCache { get; set; }
|
||||||
|
///// <summary>
|
||||||
|
///// 是否启用分库路由编译缓存
|
||||||
|
///// </summary>
|
||||||
|
//public bool? EnableDataSourceRouteCompileCache { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IShardingConfigOption<TShardingDbContext>: IShardingConfigOption where TShardingDbContext : DbContext, IShardingDbContext
|
public interface IShardingConfigOption<TShardingDbContext>: IShardingConfigOption where TShardingDbContext : DbContext, IShardingDbContext
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace ShardingCore.Sharding.MergeEngines.EnumeratorStreamMergeEngines.Enumer
|
||||||
IStreamMergeAsyncEnumerator<TEntity>[] streamsAsyncEnumerators)
|
IStreamMergeAsyncEnumerator<TEntity>[] streamsAsyncEnumerators)
|
||||||
{
|
{
|
||||||
if (StreamMergeContext.IsPaginationQuery())
|
if (StreamMergeContext.IsPaginationQuery())
|
||||||
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators,0, StreamMergeContext.GetPaginationReWriteTake());
|
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators,0, StreamMergeContext.GetPaginationReWriteTake());//内存聚合分页不可以直接获取skip必须获取skip+take的数目
|
||||||
return base.CombineInMemoryStreamMergeAsyncEnumerator(streamsAsyncEnumerators);
|
return base.CombineInMemoryStreamMergeAsyncEnumerator(streamsAsyncEnumerators);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,11 @@ namespace ShardingCore.Sharding.StreamMergeEngines.EnumeratorStreamMergeEngines.
|
||||||
|
|
||||||
private IStreamMergeAsyncEnumerator<TEntity> DoGetStreamMergeAsyncEnumerator(IStreamMergeAsyncEnumerator<TEntity>[] streamsAsyncEnumerators)
|
private IStreamMergeAsyncEnumerator<TEntity> DoGetStreamMergeAsyncEnumerator(IStreamMergeAsyncEnumerator<TEntity>[] streamsAsyncEnumerators)
|
||||||
{
|
{
|
||||||
|
if (StreamMergeContext.IsPaginationQuery() && StreamMergeContext.HasGroupQuery())
|
||||||
|
{
|
||||||
|
var multiAggregateOrderStreamMergeAsyncEnumerator = new MultiAggregateOrderStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators);
|
||||||
|
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, new[] { multiAggregateOrderStreamMergeAsyncEnumerator });
|
||||||
|
}
|
||||||
if (StreamMergeContext.IsPaginationQuery())
|
if (StreamMergeContext.IsPaginationQuery())
|
||||||
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators);
|
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators);
|
||||||
if (StreamMergeContext.HasGroupQuery())
|
if (StreamMergeContext.HasGroupQuery())
|
||||||
|
@ -91,6 +96,11 @@ namespace ShardingCore.Sharding.StreamMergeEngines.EnumeratorStreamMergeEngines.
|
||||||
public override IStreamMergeAsyncEnumerator<TEntity> CombineInMemoryStreamMergeAsyncEnumerator(
|
public override IStreamMergeAsyncEnumerator<TEntity> CombineInMemoryStreamMergeAsyncEnumerator(
|
||||||
IStreamMergeAsyncEnumerator<TEntity>[] streamsAsyncEnumerators)
|
IStreamMergeAsyncEnumerator<TEntity>[] streamsAsyncEnumerators)
|
||||||
{
|
{
|
||||||
|
if (StreamMergeContext.IsPaginationQuery() && StreamMergeContext.HasGroupQuery())
|
||||||
|
{
|
||||||
|
var multiAggregateOrderStreamMergeAsyncEnumerator = new MultiAggregateOrderStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators);
|
||||||
|
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, new[] { multiAggregateOrderStreamMergeAsyncEnumerator }, 0, StreamMergeContext.GetPaginationReWriteTake());
|
||||||
|
}
|
||||||
if (StreamMergeContext.IsPaginationQuery())
|
if (StreamMergeContext.IsPaginationQuery())
|
||||||
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators, 0, StreamMergeContext.GetPaginationReWriteTake());
|
return new PaginationStreamMergeAsyncEnumerator<TEntity>(StreamMergeContext, streamsAsyncEnumerators, 0, StreamMergeContext.GetPaginationReWriteTake());
|
||||||
return base.CombineInMemoryStreamMergeAsyncEnumerator(streamsAsyncEnumerators);
|
return base.CombineInMemoryStreamMergeAsyncEnumerator(streamsAsyncEnumerators);
|
||||||
|
|
|
@ -13,30 +13,22 @@ namespace ShardingCore.Sharding.ReadWriteConfigurations.Connectors.Abstractions
|
||||||
{
|
{
|
||||||
protected List<string> ConnectionStrings { get;}
|
protected List<string> ConnectionStrings { get;}
|
||||||
protected int Length { get; private set; }
|
protected int Length { get; private set; }
|
||||||
private readonly string _tempConnectionString;
|
//private readonly string _tempConnectionString;
|
||||||
private readonly OneByOneChecker _oneByOneChecker = new OneByOneChecker();
|
//private readonly OneByOneChecker _oneByOneChecker = new OneByOneChecker();
|
||||||
|
|
||||||
public AbstractionReadWriteConnector(string dataSourceName,IEnumerable<string> connectionStrings)
|
public AbstractionReadWriteConnector(string dataSourceName,IEnumerable<string> connectionStrings)
|
||||||
{
|
{
|
||||||
DataSourceName = dataSourceName;
|
DataSourceName = dataSourceName;
|
||||||
ConnectionStrings = connectionStrings.ToList();
|
ConnectionStrings = connectionStrings.ToList();
|
||||||
Length = ConnectionStrings.Count;
|
Length = ConnectionStrings.Count;
|
||||||
_tempConnectionString = ConnectionStrings[0];
|
//_tempConnectionString = ConnectionStrings[0];
|
||||||
}
|
}
|
||||||
public string DataSourceName { get; }
|
public string DataSourceName { get; }
|
||||||
|
|
||||||
public string GetConnectionString()
|
public string GetConnectionString()
|
||||||
{
|
|
||||||
//没有必要用太过于复杂的锁简单的操作简单的锁最简单的了
|
|
||||||
if (_oneByOneChecker.IsRunning())
|
|
||||||
{
|
|
||||||
return _tempConnectionString;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return DoGetConnectionString();
|
return DoGetConnectionString();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public abstract string DoGetConnectionString();
|
public abstract string DoGetConnectionString();
|
||||||
|
|
||||||
|
@ -47,23 +39,9 @@ namespace ShardingCore.Sharding.ReadWriteConfigurations.Connectors.Abstractions
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool AddConnectionString(string connectionString)
|
public bool AddConnectionString(string connectionString)
|
||||||
{
|
{
|
||||||
if (_oneByOneChecker.Start())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//是其他线程充分返回Connection并且感知到当前已在进行写入操作
|
|
||||||
Thread.SpinWait(1);
|
|
||||||
ConnectionStrings.Add(connectionString);
|
ConnectionStrings.Add(connectionString);
|
||||||
Length = ConnectionStrings.Count;
|
Length = ConnectionStrings.Count;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
_oneByOneChecker.Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,5 +234,7 @@ namespace ShardingCore
|
||||||
public string DefaultConnectionString { get; set; }
|
public string DefaultConnectionString { get; set; }
|
||||||
public int MaxQueryConnectionsLimit { get; set; } = Environment.ProcessorCount;
|
public int MaxQueryConnectionsLimit { get; set; } = Environment.ProcessorCount;
|
||||||
public ConnectionModeEnum ConnectionMode { get; set; } = ConnectionModeEnum.SYSTEM_AUTO;
|
public ConnectionModeEnum ConnectionMode { get; set; } = ConnectionModeEnum.SYSTEM_AUTO;
|
||||||
|
//public bool? EnableTableRouteCompileCache { get; set; }
|
||||||
|
//public bool? EnableDataSourceRouteCompileCache { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue