Table of Contents

Class HostNameBasedIdGenerator

Namespace
Quartz.Impl
Assembly
Quartz.dll

Helper base class for host name lookup requiring instance id generators.

public abstract class HostNameBasedIdGenerator : IInstanceIdGenerator
Inheritance
HostNameBasedIdGenerator
Implements
Inherited Members

Constructors

HostNameBasedIdGenerator(ILogger<HostNameBasedIdGenerator>?)

protected HostNameBasedIdGenerator(ILogger<HostNameBasedIdGenerator>? logger = null)

Parameters

logger ILogger<HostNameBasedIdGenerator>

Where a host name that had to be shortened, or a lookup that failed, is reported. A generator the container builds is handed the application's logger; one constructed by hand — UseInstanceIdGenerator(instance) — reads LogProvider, as before.

Fields

IdMaxLength

The longest instance id the scheduler state table's column holds.

protected const int IdMaxLength = 50

Field Value

int

Methods

GenerateInstanceId(CancellationToken)

Generate the instance id for a IScheduler

public abstract ValueTask<string> GenerateInstanceId(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<string>

The clusterwide unique instance id.

GetHostAddress(CancellationToken)

Looks the machine up. Overridable so that a generator can name the host some other way — a container's, a pod's — without reimplementing the shortening around it.

protected virtual ValueTask<IPHostEntry> GetHostAddress(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<IPHostEntry>

GetHostName(int, CancellationToken)

The machine's host name, shortened to maxLength and logged when it had to be.

protected ValueTask<string> GetHostName(int maxLength, CancellationToken cancellationToken = default)

Parameters

maxLength int

The most characters the caller can use.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<string>

Exceptions

SchedulerException

The host name could not be read.