Merge pull request #1144 from liangshiw/pr/1143

Resolves #1433 Make the method of the InMemoryBackgroundJobStore class to virtual
pull/1148/head^2
maliming 6 years ago committed by GitHub
commit 0d7cc1c6c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,19 +23,19 @@ namespace Volo.Abp.BackgroundJobs
_jobs = new ConcurrentDictionary<Guid, BackgroundJobInfo>();
}
public Task<BackgroundJobInfo> FindAsync(Guid jobId)
public virtual Task<BackgroundJobInfo> FindAsync(Guid jobId)
{
return Task.FromResult(_jobs.GetOrDefault(jobId));
}
public Task InsertAsync(BackgroundJobInfo jobInfo)
public virtual Task InsertAsync(BackgroundJobInfo jobInfo)
{
_jobs[jobInfo.Id] = jobInfo;
return Task.FromResult(0);
}
public Task<List<BackgroundJobInfo>> GetWaitingJobsAsync(int maxResultCount)
public virtual Task<List<BackgroundJobInfo>> GetWaitingJobsAsync(int maxResultCount)
{
var waitingJobs = _jobs.Values
.Where(t => !t.IsAbandoned && t.NextTryTime <= Clock.Now)
@ -48,14 +48,14 @@ namespace Volo.Abp.BackgroundJobs
return Task.FromResult(waitingJobs);
}
public Task DeleteAsync(Guid jobId)
public virtual Task DeleteAsync(Guid jobId)
{
_jobs.TryRemove(jobId, out _);
return Task.FromResult(0);
}
public Task UpdateAsync(BackgroundJobInfo jobInfo)
public virtual Task UpdateAsync(BackgroundJobInfo jobInfo)
{
if (jobInfo.IsAbandoned)
{

@ -19,33 +19,33 @@ namespace Volo.Abp.BackgroundJobs
BackgroundJobRepository = backgroundJobRepository;
}
public async Task<BackgroundJobInfo> FindAsync(Guid jobId)
public virtual async Task<BackgroundJobInfo> FindAsync(Guid jobId)
{
return ObjectMapper.Map<BackgroundJobRecord, BackgroundJobInfo>(
await BackgroundJobRepository.FindAsync(jobId)
);
}
public async Task InsertAsync(BackgroundJobInfo jobInfo)
public virtual async Task InsertAsync(BackgroundJobInfo jobInfo)
{
await BackgroundJobRepository.InsertAsync(
ObjectMapper.Map<BackgroundJobInfo, BackgroundJobRecord>(jobInfo)
);
}
public async Task<List<BackgroundJobInfo>> GetWaitingJobsAsync(int maxResultCount)
public virtual async Task<List<BackgroundJobInfo>> GetWaitingJobsAsync(int maxResultCount)
{
return ObjectMapper.Map<List<BackgroundJobRecord>, List<BackgroundJobInfo>>(
await BackgroundJobRepository.GetWaitingListAsync(maxResultCount)
);
}
public async Task DeleteAsync(Guid jobId)
public virtual async Task DeleteAsync(Guid jobId)
{
await BackgroundJobRepository.DeleteAsync(jobId);
}
public async Task UpdateAsync(BackgroundJobInfo jobInfo)
public virtual async Task UpdateAsync(BackgroundJobInfo jobInfo)
{
await BackgroundJobRepository.UpdateAsync(
ObjectMapper.Map<BackgroundJobInfo, BackgroundJobRecord>(jobInfo)

Loading…
Cancel
Save