Table of Contents

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

services IServiceCollection

The service collection to register into.

configure Action<HttpClientOptions>

Configures the client: the scheduler's name and how to reach it.

Returns

IServiceCollection

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

services IServiceCollection

The service collection to register into.

schedulerName string

The scheduler's name, which must match the remote scheduler's.

createHttpClient Func<IServiceProvider, HttpClient>

Builds the client to call the remote scheduler with.

jsonSerializerOptions JsonSerializerOptions

Optional serializer options for the HTTP scheduler.

Returns

IServiceCollection

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

services IServiceCollection

The service collection to register into.

schedulerName string

The scheduler's name, which must match the remote scheduler's.

httpClientName string

The name the client is registered under with AddHttpClient.

jsonSerializerOptions JsonSerializerOptions

Optional serializer options for the HTTP scheduler.

Returns

IServiceCollection