Browse Source

Use async in background jobs module.

pull/6809/head
Halil İbrahim Kalkan 6 years ago
parent
commit
1525246a4d
  1. 9
      modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/EfCoreBackgroundJobRepository.cs
  2. 11
      modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/MongoBackgroundJobRepository.cs

9
modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/EfCoreBackgroundJobRepository.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore
public EfCoreBackgroundJobRepository(
IDbContextProvider<IBackgroundJobsDbContext> dbContextProvider,
IClock clock)
IClock clock)
: base(dbContextProvider)
{
Clock = clock;
@ -23,14 +23,13 @@ namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore
public virtual async Task<List<BackgroundJobRecord>> GetWaitingListAsync(int maxResultCount)
{
return await GetWaitingListQuery(maxResultCount)
.ToListAsync();
return await (await GetWaitingListQueryAsync(maxResultCount)).ToListAsync();
}
protected virtual IQueryable<BackgroundJobRecord> GetWaitingListQuery(int maxResultCount)
protected virtual async Task<IQueryable<BackgroundJobRecord>> GetWaitingListQueryAsync(int maxResultCount)
{
var now = Clock.Now;
return DbSet
return (await GetDbSetAsync())
.Where(t => !t.IsAbandoned && t.NextTryTime <= now)
.OrderByDescending(t => t.Priority)
.ThenBy(t => t.TryCount)

11
modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/MongoBackgroundJobRepository.cs

@ -14,8 +14,8 @@ namespace Volo.Abp.BackgroundJobs.MongoDB
protected IClock Clock { get; }
public MongoBackgroundJobRepository(
IMongoDbContextProvider<IBackgroundJobsMongoDbContext> dbContextProvider,
IClock clock)
IMongoDbContextProvider<IBackgroundJobsMongoDbContext> dbContextProvider,
IClock clock)
: base(dbContextProvider)
{
Clock = clock;
@ -23,14 +23,13 @@ namespace Volo.Abp.BackgroundJobs.MongoDB
public virtual async Task<List<BackgroundJobRecord>> GetWaitingListAsync(int maxResultCount)
{
return await GetWaitingListQuery(maxResultCount)
.ToListAsync();
return await (await GetWaitingListQuery(maxResultCount)).ToListAsync();
}
protected virtual IMongoQueryable<BackgroundJobRecord> GetWaitingListQuery(int maxResultCount)
protected virtual async Task<IMongoQueryable<BackgroundJobRecord>> GetWaitingListQuery(int maxResultCount)
{
var now = Clock.Now;
return GetMongoQueryable()
return (await GetMongoQueryableAsync())
.Where(t => !t.IsAbandoned && t.NextTryTime <= now)
.OrderByDescending(t => t.Priority)
.ThenBy(t => t.TryCount)

Loading…
Cancel
Save