Class HostNameBasedIdGenerator
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
loggerILogger<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
Methods
GenerateInstanceId(CancellationToken)
Generate the instance id for a IScheduler
public abstract ValueTask<string> GenerateInstanceId(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
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
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
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
maxLengthintThe most characters the caller can use.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
Exceptions
- SchedulerException
The host name could not be read.