Class QuartzHttpClientServiceCollectionExtensions
- Namespace
- Quartz
- Assembly
- Quartz.HttpClient.dll
Registers schedulers that live in another process and are driven over Quartz's HTTP API.
public static class QuartzHttpClientServiceCollectionExtensions
- Inheritance
-
QuartzHttpClientServiceCollectionExtensions
- Inherited Members
Remarks
A remote scheduler is registered the same way a local one is: keyed by its name, so
GetRequiredKeyedService<IScheduler>("reporting") and
[FromKeyedServices("reporting")] IScheduler reach it, and unkeyed as well while it is the only
scheduler in the container. Before 4.0 a second remote scheduler needed a marker interface of its own,
implemented by a type emitted at runtime; the service key says the same thing without the reflection.
That unkeyed registration is a TryAdd, so in a container that also holds a local scheduler the
local one owns GetRequiredService<IScheduler>() and the remote one is reached by name. To
get that, call AddQuartz() before this — the other order is refused rather than left
to be discovered, since a container in which "the scheduler" turned out to be somebody else's process
is not something anything downstream can notice.
Methods
AddQuartzHttpClient(IServiceCollection, Action<HttpClientOptions>)
Registers a scheduler that drives a remote one over HTTP.
public static IServiceCollection AddQuartzHttpClient(this IServiceCollection services, Action<HttpClientOptions> configure)
Parameters
servicesIServiceCollectionThe service collection to register into.
configureAction<HttpClientOptions>Configures the client: the scheduler's name and how to reach it.
Returns
AddQuartzHttpClient(IServiceCollection, string, Func<IServiceProvider, HttpClient>, JsonSerializerOptions?)
Registers a scheduler that drives a remote one over HTTP, with a client built by the given factory rather than resolved by name.
public static IServiceCollection AddQuartzHttpClient(this IServiceCollection services, string schedulerName, Func<IServiceProvider, HttpClient> createHttpClient, JsonSerializerOptions? jsonSerializerOptions = null)
Parameters
servicesIServiceCollectionThe service collection to register into.
schedulerNamestringThe scheduler's name, which must match the remote scheduler's.
createHttpClientFunc<IServiceProvider, HttpClient>Builds the client to call the remote scheduler with.
jsonSerializerOptionsJsonSerializerOptionsOptional serializer options for the HTTP scheduler.
Returns
Remarks
The factory runs once, when the scheduler is first resolved, and is handed the container. The client it returns belongs to whoever created it and is never disposed by the scheduler.
AddQuartzHttpClient(IServiceCollection, string, string, JsonSerializerOptions?)
Registers a scheduler that drives a remote one over HTTP, using a named IHttpClientFactory client.
public static IServiceCollection AddQuartzHttpClient(this IServiceCollection services, string schedulerName, string httpClientName, JsonSerializerOptions? jsonSerializerOptions = null)
Parameters
servicesIServiceCollectionThe service collection to register into.
schedulerNamestringThe scheduler's name, which must match the remote scheduler's.
httpClientNamestringThe name the client is registered under with
AddHttpClient.jsonSerializerOptionsJsonSerializerOptionsOptional serializer options for the HTTP scheduler.