对JobRunService进行日志的构造函数依赖移除
This commit is contained in:
parent
1c8618ebbd
commit
d0420888bc
|
@ -31,7 +31,7 @@ namespace ShardingCore.Bootstrappers
|
|||
/// <typeparam name="TEntity"></typeparam>
|
||||
public class EntityMetadataInitializer<TEntity>: IEntityMetadataInitializer where TEntity:class
|
||||
{
|
||||
private static readonly ILogger<EntityMetadataInitializer<TEntity>> _logger=InternalLoggerFactory.CreateLogger<EntityMetadataInitializer<TEntity>>();
|
||||
private static readonly ILogger<EntityMetadataInitializer<TEntity>> _logger=ShardingLoggerFactory.CreateLogger<EntityMetadataInitializer<TEntity>>();
|
||||
private readonly Type _shardingEntityType;
|
||||
private readonly IShardingProvider _shardingProvider;
|
||||
private readonly IShardingRouteConfigOptions _shardingRouteConfigOptions;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ShardingCore.Bootstrappers
|
|||
|
||||
public ShardingInitializer(IShardingProvider shardingProvider)
|
||||
{
|
||||
_logger = InternalLoggerFactory.DefaultFactory.CreateLogger<ShardingBootstrapper>();
|
||||
_logger = ShardingLoggerFactory.DefaultFactory.CreateLogger<ShardingBootstrapper>();
|
||||
_shardingProvider = shardingProvider;
|
||||
_routeConfigOptions = shardingProvider.GetRequiredService<IShardingRouteConfigOptions>();
|
||||
_entityMetadataManager = shardingProvider.GetRequiredService<IEntityMetadataManager>();
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace ShardingCore.Core.RuntimeContexts
|
|||
|
||||
public void UseLogfactory(ILoggerFactory loggerFactory)
|
||||
{
|
||||
InternalLoggerFactory.DefaultFactory = loggerFactory;
|
||||
ShardingLoggerFactory.DefaultFactory = loggerFactory;
|
||||
}
|
||||
|
||||
public void UseApplicationServiceProvider(IServiceProvider applicationServiceProvider)
|
||||
|
|
|
@ -1,175 +1,166 @@
|
|||
// using Microsoft.EntityFrameworkCore;
|
||||
// using Microsoft.Extensions.DependencyInjection;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using ShardingCore.Core.EntityMetadatas;
|
||||
// using ShardingCore.Core.PhysicTables;
|
||||
// using ShardingCore.Core.ShardingConfigurations.Abstractions;
|
||||
// using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
|
||||
// using ShardingCore.Core.VirtualDatabase.VirtualDataSources.Abstractions;
|
||||
// using ShardingCore.Core.VirtualDatabase.VirtualTables;
|
||||
// using ShardingCore.Core.VirtualRoutes.TableRoutes.RouteTails.Abstractions;
|
||||
// using ShardingCore.Core.VirtualTables;
|
||||
// using ShardingCore.Exceptions;
|
||||
// using ShardingCore.Extensions;
|
||||
// using ShardingCore.Sharding.Abstractions;
|
||||
// using ShardingCore.TableCreator;
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Threading;
|
||||
// using ShardingCore.Logger;
|
||||
//
|
||||
// namespace ShardingCore.DynamicDataSources
|
||||
// {
|
||||
// public class DataSourceInitializer<TShardingDbContext> : IDataSourceInitializer<TShardingDbContext>
|
||||
// where TShardingDbContext : DbContext, IShardingDbContext
|
||||
// {
|
||||
// private static readonly ILogger<DataSourceInitializer<TShardingDbContext>> _logger =
|
||||
// InternalLoggerFactory.CreateLogger<DataSourceInitializer<TShardingDbContext>>();
|
||||
//
|
||||
// private readonly IShardingRouteConfigOptions<TShardingDbContext> _routeConfigOptions;
|
||||
// private readonly IVirtualDataSourceManager<TShardingDbContext> _virtualDataSourceManager;
|
||||
// private readonly IRouteTailFactory _routeTailFactory;
|
||||
// private readonly IVirtualTableManager<TShardingDbContext> _virtualTableManager;
|
||||
// private readonly IEntityMetadataManager<TShardingDbContext> _entityMetadataManager;
|
||||
// private readonly IShardingTableCreator<TShardingDbContext> _tableCreator;
|
||||
//
|
||||
// public DataSourceInitializer(
|
||||
// IShardingRouteConfigOptions<TShardingDbContext> routeConfigOptions,
|
||||
// IVirtualDataSourceManager<TShardingDbContext> virtualDataSourceManager,
|
||||
// IRouteTailFactory routeTailFactory, IVirtualTableManager<TShardingDbContext> virtualTableManager,
|
||||
// IEntityMetadataManager<TShardingDbContext> entityMetadataManager,
|
||||
// IShardingTableCreator<TShardingDbContext> shardingTableCreator)
|
||||
// {
|
||||
// _routeConfigOptions = routeConfigOptions;
|
||||
// _virtualDataSourceManager = virtualDataSourceManager;
|
||||
// _routeTailFactory = routeTailFactory;
|
||||
// _virtualTableManager = virtualTableManager;
|
||||
// _entityMetadataManager = entityMetadataManager;
|
||||
// _tableCreator = shardingTableCreator;
|
||||
// }
|
||||
//
|
||||
// public void InitConfigure(IVirtualDataSource<TShardingDbContext> virtualDataSource, string dataSourceName)
|
||||
// {
|
||||
// using (_virtualDataSourceManager.CreateScope(virtualDataSource.ConfigId))
|
||||
// {
|
||||
// // var createDatabase = !needCreateDatabase.HasValue || needCreateDatabase.Value;
|
||||
// //
|
||||
// // if ((_routeConfigOptions.EnsureCreatedWithOutShardingTable || !isOnStart)&&createDatabase)
|
||||
// // EnsureCreated(virtualDataSource, context, dataSourceName);
|
||||
// // else if (_routeConfigOptions.CreateDataBaseOnlyOnStart.GetValueOrDefault()&& createDatabase)
|
||||
// // {
|
||||
// // EnsureCreateDataBaseOnly(context, dataSourceName);
|
||||
// // }
|
||||
//
|
||||
// // var tableEnsureManager = virtualDataSource.ConfigurationParams.TableEnsureManager;
|
||||
// // ////获取数据库存在的所有的表
|
||||
// // var existTables = tableEnsureManager?.GetExistTables(context, dataSourceName) ??
|
||||
// // new HashSet<string>();
|
||||
// var allShardingEntities = _entityMetadataManager.GetAllShardingEntities();
|
||||
// foreach (var entityType in allShardingEntities)
|
||||
// {
|
||||
// //如果是默认数据源
|
||||
// if (virtualDataSource.IsDefault(dataSourceName))
|
||||
// {
|
||||
// if (_entityMetadataManager.IsShardingTable(entityType))
|
||||
// {
|
||||
// var virtualTable = _virtualTableManager.GetVirtualTable(entityType);
|
||||
// InitVirtualTable(virtualTable);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //非默认数据源
|
||||
// if (_entityMetadataManager.IsShardingDataSource(entityType))
|
||||
// {
|
||||
// var virtualDataSourceRoute = virtualDataSource.GetRoute(entityType);
|
||||
// if (virtualDataSourceRoute.GetAllDataSourceNames().Contains(dataSourceName))
|
||||
// {
|
||||
// if (_entityMetadataManager.IsShardingTable(entityType))
|
||||
// {
|
||||
// var virtualTable = _virtualTableManager.GetVirtualTable(entityType);
|
||||
// //创建表
|
||||
// InitVirtualTable(virtualTable);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void InitVirtualTable(IVirtualTable virtualTable)
|
||||
// {
|
||||
// foreach (var tail in virtualTable.GetVirtualRoute().GetTails())
|
||||
// {
|
||||
// var defaultPhysicTable = new DefaultPhysicTable(virtualTable, tail);
|
||||
// virtualTable.AddPhysicTable(defaultPhysicTable);
|
||||
// }
|
||||
// }
|
||||
// //
|
||||
// // private bool NeedCreateTable(EntityMetadata entityMetadata)
|
||||
// // {
|
||||
// // if (entityMetadata.AutoCreateTable.HasValue)
|
||||
// // {
|
||||
// // if (entityMetadata.AutoCreateTable.Value)
|
||||
// // return entityMetadata.AutoCreateTable.Value;
|
||||
// // else
|
||||
// // {
|
||||
// // if (entityMetadata.AutoCreateDataSourceTable.HasValue)
|
||||
// // return entityMetadata.AutoCreateDataSourceTable.Value;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // if (entityMetadata.AutoCreateDataSourceTable.HasValue)
|
||||
// // {
|
||||
// // if (entityMetadata.AutoCreateDataSourceTable.Value)
|
||||
// // return entityMetadata.AutoCreateDataSourceTable.Value;
|
||||
// // else
|
||||
// // {
|
||||
// // if (entityMetadata.AutoCreateTable.HasValue)
|
||||
// // return entityMetadata.AutoCreateTable.Value;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // return _routeConfigOptions.CreateShardingTableOnStart.GetValueOrDefault();
|
||||
// // }
|
||||
// //
|
||||
// // private void EnsureCreated(IVirtualDataSource<TShardingDbContext> virtualDataSource, DbContext context,
|
||||
// // string dataSourceName)
|
||||
// // {
|
||||
// // if (context is IShardingDbContext shardingDbContext)
|
||||
// // {
|
||||
// // using (var dbContext =
|
||||
// // shardingDbContext.GetDbContext(dataSourceName, false,
|
||||
// // _routeTailFactory.Create(string.Empty, false)))
|
||||
// // {
|
||||
// // var isDefault = virtualDataSource.IsDefault(dataSourceName);
|
||||
// //
|
||||
// // if (isDefault)
|
||||
// // {
|
||||
// // dbContext.RemoveDbContextRelationModelThatIsShardingTable();
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // dbContext.RemoveDbContextAllRelationModelThatIsNoSharding();
|
||||
// // }
|
||||
// //
|
||||
// // dbContext.Database.EnsureCreated();
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // private void EnsureCreateDataBaseOnly(DbContext context, string dataSourceName)
|
||||
// // {
|
||||
// // if (context is IShardingDbContext shardingDbContext)
|
||||
// // {
|
||||
// // using (var dbContext = shardingDbContext.GetDbContext(dataSourceName, false,
|
||||
// // _routeTailFactory.Create(string.Empty, false)))
|
||||
// // {
|
||||
// // dbContext.RemoveDbContextAllRelationModel();
|
||||
// // dbContext.Database.EnsureCreated();
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShardingCore.Core.EntityMetadatas;
|
||||
using ShardingCore.Core.ShardingConfigurations.Abstractions;
|
||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
|
||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RouteTails.Abstractions;
|
||||
using ShardingCore.TableCreator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
||||
using ShardingCore.Logger;
|
||||
|
||||
namespace ShardingCore.DynamicDataSources
|
||||
{
|
||||
public class DataSourceInitializer : IDataSourceInitializer
|
||||
{
|
||||
private static readonly ILogger<DataSourceInitializer> _logger =
|
||||
ShardingLoggerFactory.CreateLogger<DataSourceInitializer>();
|
||||
|
||||
private readonly IShardingRouteConfigOptions _routeConfigOptions;
|
||||
private readonly IVirtualDataSource _virtualDataSource;
|
||||
private readonly IRouteTailFactory _routeTailFactory;
|
||||
private readonly ITableRouteManager _tableRouteManager;
|
||||
private readonly IEntityMetadataManager _entityMetadataManager;
|
||||
private readonly IShardingTableCreator _tableCreator;
|
||||
|
||||
public DataSourceInitializer(
|
||||
IShardingRouteConfigOptions routeConfigOptions,
|
||||
IVirtualDataSource virtualDataSource,
|
||||
IRouteTailFactory routeTailFactory,
|
||||
ITableRouteManager tableRouteManager,
|
||||
IEntityMetadataManager entityMetadataManager,
|
||||
IShardingTableCreator shardingTableCreator)
|
||||
{
|
||||
_routeConfigOptions = routeConfigOptions;
|
||||
_virtualDataSource = virtualDataSource;
|
||||
_routeTailFactory = routeTailFactory;
|
||||
_tableRouteManager = tableRouteManager;
|
||||
_entityMetadataManager = entityMetadataManager;
|
||||
_tableCreator = shardingTableCreator;
|
||||
}
|
||||
|
||||
public void InitConfigure(string dataSourceName)
|
||||
{
|
||||
// // var createDatabase = !needCreateDatabase.HasValue || needCreateDatabase.Value;
|
||||
// //
|
||||
// // if ((_routeConfigOptions.EnsureCreatedWithOutShardingTable || !isOnStart)&&createDatabase)
|
||||
// // EnsureCreated(virtualDataSource, context, dataSourceName);
|
||||
// // else if (_routeConfigOptions.CreateDataBaseOnlyOnStart.GetValueOrDefault()&& createDatabase)
|
||||
// // {
|
||||
// // EnsureCreateDataBaseOnly(context, dataSourceName);
|
||||
// // }
|
||||
//
|
||||
// // var tableEnsureManager = virtualDataSource.ConfigurationParams.TableEnsureManager;
|
||||
// // ////获取数据库存在的所有的表
|
||||
// // var existTables = tableEnsureManager?.GetExistTables(context, dataSourceName) ??
|
||||
// // new HashSet<string>();
|
||||
// var allShardingEntities = _entityMetadataManager.GetAllShardingEntities();
|
||||
// foreach (var entityType in allShardingEntities)
|
||||
// {
|
||||
// //如果是默认数据源
|
||||
// if (_virtualDataSource.IsDefault(dataSourceName))
|
||||
// {
|
||||
// if (_entityMetadataManager.IsShardingTable(entityType))
|
||||
// {
|
||||
// var virtualTable = _virtualTableManager.GetVirtualTable(entityType);
|
||||
// InitVirtualTable(virtualTable);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //非默认数据源
|
||||
// if (_entityMetadataManager.IsShardingDataSource(entityType))
|
||||
// {
|
||||
// var virtualDataSourceRoute = virtualDataSource.GetRoute(entityType);
|
||||
// if (virtualDataSourceRoute.GetAllDataSourceNames().Contains(dataSourceName))
|
||||
// {
|
||||
// if (_entityMetadataManager.IsShardingTable(entityType))
|
||||
// {
|
||||
// var virtualTable = _virtualTableManager.GetVirtualTable(entityType);
|
||||
// //创建表
|
||||
// InitVirtualTable(virtualTable);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// private void InitVirtualTable(IVirtualTable virtualTable)
|
||||
// {
|
||||
// foreach (var tail in virtualTable.GetVirtualRoute().GetTails())
|
||||
// {
|
||||
// var defaultPhysicTable = new DefaultPhysicTable(virtualTable, tail);
|
||||
// virtualTable.AddPhysicTable(defaultPhysicTable);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private bool NeedCreateTable(EntityMetadata entityMetadata)
|
||||
// {
|
||||
// if (entityMetadata.AutoCreateTable.HasValue)
|
||||
// {
|
||||
// if (entityMetadata.AutoCreateTable.Value)
|
||||
// return entityMetadata.AutoCreateTable.Value;
|
||||
// else
|
||||
// {
|
||||
// if (entityMetadata.AutoCreateDataSourceTable.HasValue)
|
||||
// return entityMetadata.AutoCreateDataSourceTable.Value;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (entityMetadata.AutoCreateDataSourceTable.HasValue)
|
||||
// {
|
||||
// if (entityMetadata.AutoCreateDataSourceTable.Value)
|
||||
// return entityMetadata.AutoCreateDataSourceTable.Value;
|
||||
// else
|
||||
// {
|
||||
// if (entityMetadata.AutoCreateTable.HasValue)
|
||||
// return entityMetadata.AutoCreateTable.Value;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return _routeConfigOptions.CreateShardingTableOnStart.GetValueOrDefault();
|
||||
// }
|
||||
//
|
||||
// private void EnsureCreated(IVirtualDataSource<TShardingDbContext> virtualDataSource, DbContext context,
|
||||
// string dataSourceName)
|
||||
// {
|
||||
// if (context is IShardingDbContext shardingDbContext)
|
||||
// {
|
||||
// using (var dbContext =
|
||||
// shardingDbContext.GetDbContext(dataSourceName, false,
|
||||
// _routeTailFactory.Create(string.Empty, false)))
|
||||
// {
|
||||
// var isDefault = virtualDataSource.IsDefault(dataSourceName);
|
||||
//
|
||||
// if (isDefault)
|
||||
// {
|
||||
// dbContext.RemoveDbContextRelationModelThatIsShardingTable();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dbContext.RemoveDbContextAllRelationModelThatIsNoSharding();
|
||||
// }
|
||||
//
|
||||
// dbContext.Database.EnsureCreated();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void EnsureCreateDataBaseOnly(DbContext context, string dataSourceName)
|
||||
// {
|
||||
// if (context is IShardingDbContext shardingDbContext)
|
||||
// {
|
||||
// using (var dbContext = shardingDbContext.GetDbContext(dataSourceName, false,
|
||||
// _routeTailFactory.Create(string.Empty, false)))
|
||||
// {
|
||||
// dbContext.RemoveDbContextAllRelationModel();
|
||||
// dbContext.Database.EnsureCreated();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -1,21 +1,20 @@
|
|||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using System.Text;
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.EntityFrameworkCore;
|
||||
// using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
|
||||
// using ShardingCore.Sharding.Abstractions;
|
||||
//
|
||||
// namespace ShardingCore.DynamicDataSources
|
||||
// {
|
||||
// public interface IDataSourceInitializer<TShardingDbContext> where TShardingDbContext : DbContext, IShardingDbContext
|
||||
// {
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="virtualDataSource"></param>
|
||||
// /// <param name="dataSourceName"></param>
|
||||
// void InitConfigure(IVirtualDataSource<TShardingDbContext> virtualDataSource, string dataSourceName);
|
||||
// }
|
||||
// }
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
|
||||
using ShardingCore.Sharding.Abstractions;
|
||||
|
||||
namespace ShardingCore.DynamicDataSources
|
||||
{
|
||||
public interface IDataSourceInitializer
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dataSourceName"></param>
|
||||
void InitConfigure( string dataSourceName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace ShardingCore.EFCores
|
|||
public class ShardingModelCustomizer : ModelCustomizer
|
||||
{
|
||||
private static readonly ILogger<ShardingModelCustomizer> _logger =
|
||||
InternalLoggerFactory.CreateLogger<ShardingModelCustomizer>();
|
||||
ShardingLoggerFactory.CreateLogger<ShardingModelCustomizer>();
|
||||
|
||||
public ShardingModelCustomizer(ModelCustomizerDependencies dependencies) : base(dependencies)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ShardingCore.Logger;
|
||||
|
||||
namespace ShardingCore.Jobs
|
||||
{
|
||||
|
@ -18,8 +19,9 @@ namespace ShardingCore.Jobs
|
|||
[ExcludeFromCodeCoverage]
|
||||
internal class JobRunnerService
|
||||
{
|
||||
private static readonly ILogger<JobRunnerService> _logger =
|
||||
ShardingLoggerFactory.CreateLogger<JobRunnerService>();
|
||||
private readonly IJobManager _jobManager;
|
||||
private readonly ILogger<JobRunnerService> _logger;
|
||||
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||
private const long DEFAULT_MILLIS = 1000L;
|
||||
|
||||
|
@ -28,10 +30,9 @@ namespace ShardingCore.Jobs
|
|||
/// </summary>
|
||||
private const long MAX_DELAY_MILLIS = 30000L;
|
||||
|
||||
public JobRunnerService(IJobManager jobManager, ILogger<JobRunnerService> logger)
|
||||
public JobRunnerService(IJobManager jobManager)
|
||||
{
|
||||
_jobManager = jobManager;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task StartAsync()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
|
@ -14,7 +14,7 @@ namespace ShardingCore.Logger
|
|||
/// Author: xjm
|
||||
/// Created: 2022/5/18 10:02:25
|
||||
/// Email: 326308290@qq.com
|
||||
public sealed class InternalLoggerFactory
|
||||
public sealed class ShardingLoggerFactory
|
||||
{
|
||||
static ILoggerFactory _defaultFactory;
|
||||
|
|
@ -381,13 +381,13 @@ namespace ShardingCore.Sharding
|
|||
// entry.State = EntityState.Unchanged;
|
||||
// genericDbContext.Entry(entry.Entity).State = entityState;
|
||||
//}
|
||||
public override int SaveChanges()
|
||||
{
|
||||
|
||||
if (IsExecutor)
|
||||
return base.SaveChanges();
|
||||
return this.SaveChanges(true);
|
||||
}
|
||||
// public override int SaveChanges()
|
||||
// {
|
||||
//
|
||||
// if (IsExecutor)
|
||||
// return base.SaveChanges();
|
||||
// return this.SaveChanges(true);
|
||||
// }
|
||||
|
||||
public override int SaveChanges(bool acceptAllChangesOnSuccess)
|
||||
{
|
||||
|
@ -413,12 +413,12 @@ namespace ShardingCore.Sharding
|
|||
}
|
||||
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
if (IsExecutor)
|
||||
return base.SaveChangesAsync(cancellationToken);
|
||||
return this.SaveChangesAsync(true, cancellationToken);
|
||||
}
|
||||
// public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
// {
|
||||
// if (IsExecutor)
|
||||
// return base.SaveChangesAsync(cancellationToken);
|
||||
// return this.SaveChangesAsync(true, cancellationToken);
|
||||
// }
|
||||
|
||||
public override async Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace ShardingCore.Sharding.ShardingDbContextExecutors
|
|||
public class DataSourceDbContext : IDataSourceDbContext
|
||||
{
|
||||
private static readonly ILogger<DataSourceDbContext> _logger =
|
||||
InternalLoggerFactory.CreateLogger<DataSourceDbContext>();
|
||||
ShardingLoggerFactory.CreateLogger<DataSourceDbContext>();
|
||||
|
||||
private static readonly IComparer<string> _comparer = new NoShardingFirstComparer();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
/// </summary>
|
||||
public class DefaultShardingCompilerExecutor: IShardingCompilerExecutor
|
||||
{
|
||||
private static readonly ILogger<DefaultShardingCompilerExecutor> _logger=InternalLoggerFactory.CreateLogger<DefaultShardingCompilerExecutor>();
|
||||
private static readonly ILogger<DefaultShardingCompilerExecutor> _logger=ShardingLoggerFactory.CreateLogger<DefaultShardingCompilerExecutor>();
|
||||
private readonly IShardingTrackQueryExecutor _shardingTrackQueryExecutor;
|
||||
private readonly IQueryCompilerContextFactory _queryCompilerContextFactory;
|
||||
private readonly IPrepareParser _prepareParser;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace ShardingCore.Sharding.ShardingQueryExecutors
|
|||
*/
|
||||
public class DefaultShardingQueryExecutor : IShardingQueryExecutor
|
||||
{
|
||||
private static readonly ILogger<DefaultShardingQueryExecutor> _logger=InternalLoggerFactory.CreateLogger<DefaultShardingQueryExecutor>();
|
||||
private static readonly ILogger<DefaultShardingQueryExecutor> _logger=ShardingLoggerFactory.CreateLogger<DefaultShardingQueryExecutor>();
|
||||
private readonly IStreamMergeContextFactory _streamMergeContextFactory;
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
private readonly ITableRouteRuleEngineFactory _tableRouteRuleEngineFactory;
|
||||
|
||||
private static readonly ILogger<QueryCompilerContextFactory> _logger =
|
||||
InternalLoggerFactory.CreateLogger<QueryCompilerContextFactory>();
|
||||
ShardingLoggerFactory.CreateLogger<QueryCompilerContextFactory>();
|
||||
private static readonly IQueryableCombine _enumerableQueryableCombine;
|
||||
private static readonly IQueryableCombine _allQueryableCombine;
|
||||
private static readonly IQueryableCombine _constantQueryableCombine;
|
||||
|
|
|
@ -36,6 +36,7 @@ using ShardingCore.Core.UnionAllMergeShardingProviders.Abstractions;
|
|||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources.Abstractions;
|
||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||
using ShardingCore.DynamicDataSources;
|
||||
using ShardingCore.Sharding.MergeContexts;
|
||||
using ShardingCore.Sharding.ParallelTables;
|
||||
using ShardingCore.Sharding.Parsers;
|
||||
|
@ -109,6 +110,7 @@ namespace ShardingCore
|
|||
{
|
||||
services.TryAddSingleton<IShardingInitializer, ShardingInitializer>();
|
||||
services.TryAddSingleton<IShardingBootstrapper, ShardingBootstrapper>();
|
||||
services.TryAddSingleton<IDataSourceInitializer, DataSourceInitializer>();
|
||||
services.TryAddSingleton<ITableRouteManager, TableRouteManager>();
|
||||
services.TryAddSingleton<IVirtualDataSourceConfigurationParams, SimpleVirtualDataSourceConfigurationParams>();
|
||||
//分表dbcontext创建
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace ShardingCore.TableCreator
|
|||
public class ShardingTableCreator : IShardingTableCreator
|
||||
{
|
||||
private static readonly ILogger<ShardingTableCreator> _logger =
|
||||
InternalLoggerFactory.CreateLogger<ShardingTableCreator>();
|
||||
ShardingLoggerFactory.CreateLogger<ShardingTableCreator>();
|
||||
|
||||
private readonly IShardingProvider _shardingProvider;
|
||||
private readonly IShardingRouteConfigOptions _routeConfigOptions;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ShardingCore.VirtualRoutes.Abstractions
|
|||
private static readonly object APPEND_LOCK = new object();
|
||||
|
||||
private static readonly ILogger<AbstractShardingAutoCreateOperatorVirtualTableRoute<TEntity, TKey>> _logger =
|
||||
InternalLoggerFactory.CreateLogger<AbstractShardingAutoCreateOperatorVirtualTableRoute<TEntity, TKey>>();
|
||||
ShardingLoggerFactory.CreateLogger<AbstractShardingAutoCreateOperatorVirtualTableRoute<TEntity, TKey>>();
|
||||
|
||||
private readonly SafeReadAppendList<string> _tails = new SafeReadAppendList<string>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue