修复部分bug增加更多功能
This commit is contained in:
parent
36d8709efe
commit
7837e78e55
|
@ -13,7 +13,6 @@ namespace Sample.MySql
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var list = Enumerable.Range(1,3).Select(o=>(o%100).ToString().PadLeft(2,'0')).ToList();
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
namespace ShardingCore.Bootstrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// 主要的分表初始化器,不再需要手动调用,<code>IShardingRuntimeContext初始化的时候会调用</code>
|
||||
/// 主要的分片初始化器,需要手动调用,如果你的分片路由存在定时执行的job譬如
|
||||
/// 系统默认的时间分片的情况下那么需要调用<code>IShardingRuntimeContext初始化的时候会调用</code>
|
||||
/// </summary>
|
||||
public interface IShardingBootstrapper
|
||||
{
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace ShardingCore.Bootstrappers
|
|||
if (!_doOnlyOnce.IsUnDo())
|
||||
return;
|
||||
_logger.LogDebug("sharding core starting......");
|
||||
|
||||
_logger.LogDebug("sharding core initialize entity metadata......");
|
||||
InitializeEntityMetadata();
|
||||
_logger.LogDebug("sharding core initialize parallel table......");
|
||||
|
@ -63,7 +62,6 @@ namespace ShardingCore.Bootstrappers
|
|||
|
||||
var entityMetadataInitializer =(IEntityMetadataInitializer)_shardingProvider.CreateInstance(entityMetadataInitializerType);
|
||||
entityMetadataInitializer.Initialize();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace ShardingCore.Core.ServiceProviders
|
|||
/// <returns></returns>
|
||||
TService GetRequiredService<TService>(bool tryApplicationServiceProvider=true);
|
||||
|
||||
IServiceProvider ApplicationServiceProvider { get; }
|
||||
|
||||
IShardingScope CreateScope();
|
||||
}
|
||||
}
|
|
@ -44,6 +44,8 @@ namespace ShardingCore.Core.ServiceProviders
|
|||
return (TService)GetRequiredService(typeof(TService),tryApplicationServiceProvider);
|
||||
}
|
||||
|
||||
public IServiceProvider ApplicationServiceProvider => _applicationServiceProvider;
|
||||
|
||||
public IShardingScope CreateScope()
|
||||
{
|
||||
return new ShardingScope(_internalServiceProvider.CreateScope(), _applicationServiceProvider?.CreateScope());
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using ShardingCore.Exceptions;
|
||||
using ShardingCore.Jobs.Abstaractions;
|
||||
using ShardingCore.Jobs.Cron;
|
||||
|
||||
|
@ -20,6 +21,15 @@ namespace ShardingCore.Jobs.Impls
|
|||
JobInstance = job;
|
||||
JobName = job.JobName;
|
||||
JobCronExpressions = job.GetJobCronExpressions();
|
||||
if (JobCronExpressions == null)
|
||||
{
|
||||
throw new ArgumentException($" {nameof(JobCronExpressions)} is null");
|
||||
}
|
||||
|
||||
if (JobCronExpressions.Any(o => o is null))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(JobCronExpressions)} has null element");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保证多线程只有一个清理操作
|
||||
|
@ -79,6 +89,7 @@ namespace ShardingCore.Jobs.Impls
|
|||
/// </summary>
|
||||
public void CalcNextUtcTime()
|
||||
{
|
||||
|
||||
this.NextUtcTime= JobCronExpressions.Select(cron => new CronExpression(cron).GetTimeAfter(DateTime.UtcNow)).Min();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue