mirror of https://github.com/abpframework/abp.git
Browse Source
Introduce AnonymousJobExecutionContext and switch anonymous job handler APIs to accept it (Func<AnonymousJobExecutionContext, CancellationToken, Task> / Action<AnonymousJobExecutionContext, CancellationToken>). Update AbpBackgroundJobOptions, IAnonymousJobHandlerRegistry, AnonymousJobHandlerRegistry and AnonymousJobExecutorAsyncBackgroundJob to use the new context and to obtain a cancellation token via ICancellationTokenProvider. Update all callsites (tests, demo module, sample job creator) and documentation to show registering/enqueuing anonymous handlers by name and explain Hangfire display behavior. Also add a .cursor hooks state file. The demo no longer skips enqueuing anonymous jobs for RabbitMQ in this change.pull/25059/head
11 changed files with 127 additions and 39 deletions
@ -0,0 +1,22 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs; |
|||
|
|||
public class AnonymousJobExecutionContext |
|||
{ |
|||
public string JobName { get; } |
|||
|
|||
public string JsonData { get; } |
|||
|
|||
public IServiceProvider ServiceProvider { get; } |
|||
|
|||
public AnonymousJobExecutionContext( |
|||
string jobName, |
|||
string jsonData, |
|||
IServiceProvider serviceProvider) |
|||
{ |
|||
JobName = Check.NotNullOrWhiteSpace(jobName, nameof(jobName)); |
|||
JsonData = Check.NotNull(jsonData, nameof(jsonData)); |
|||
ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider)); |
|||
} |
|||
} |
|||
@ -1,18 +1,17 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs; |
|||
|
|||
public interface IAnonymousJobHandlerRegistry |
|||
{ |
|||
void Register(string jobName, Func<string, IServiceProvider, System.Threading.CancellationToken, Task> handler); |
|||
void Register(string jobName, Func<AnonymousJobExecutionContext, System.Threading.CancellationToken, Task> handler); |
|||
|
|||
void Register(string jobName, Action<string, IServiceProvider, System.Threading.CancellationToken> handler); |
|||
void Register(string jobName, Action<AnonymousJobExecutionContext, System.Threading.CancellationToken> handler); |
|||
|
|||
bool Unregister(string jobName); |
|||
|
|||
bool IsRegistered(string jobName); |
|||
|
|||
Func<string, IServiceProvider, System.Threading.CancellationToken, Task>? Get(string jobName); |
|||
Func<AnonymousJobExecutionContext, System.Threading.CancellationToken, Task>? Get(string jobName); |
|||
} |
|||
|
|||
Loading…
Reference in new issue