< Summary

Information
Class: Elsa.Hosting.Management.Options.ApplicationInstanceOptions
Assembly: Elsa.Hosting.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Hosting.Management/Options/ApplicationInstanceOptions.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 45
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_InstanceName()100%11100%
get_InstanceNameEnvironmentVariable()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Hosting.Management/Options/ApplicationInstanceOptions.cs

#LineLine coverage
 1namespace Elsa.Hosting.Management.Options;
 2
 3/// <summary>
 4/// Options that control how the name of the current application instance is determined.
 5/// </summary>
 6/// <remarks>
 7/// The instance name is used to name per-instance transport entities, such as the Azure Service Bus
 8/// change-token subscription and queue (<c>{instanceName}-elsa-trigger-change-token-signal</c>).
 9/// By default a random name is generated for every process start, which means a new entity is created
 10/// on every restart. Under transports with a per-topic entity limit (for example Azure Service Bus,
 11/// which caps a topic at 2,000 subscriptions), these orphaned entities can accumulate across restarts
 12/// until the limit is reached and new instances can no longer start. Providing a <i>stable</i> name
 13/// that is reused across restarts of the same logical instance keeps the number of entities bounded.
 14///
 15/// A stable name must be both stable across restarts of the same instance and unique across instances
 16/// that run at the same time. In Kubernetes a StatefulSet provides exactly this (each pod keeps its
 17/// ordinal hostname across restarts); for a Deployment the pod name can be projected via the Downward
 18/// API (for example <c>metadata.name</c>).
 19/// </remarks>
 20public class ApplicationInstanceOptions
 21{
 22    /// <summary>
 23    /// An explicit, stable, unique-per-instance name. When set, this value is used directly and takes
 24    /// precedence over <see cref="InstanceNameEnvironmentVariable"/>.
 25    /// </summary>
 26    /// <remarks>
 27    /// Keep this value short enough for downstream transport entity names. For Azure Service Bus, the
 28    /// change-token subscription name must fit in 50 characters, leaving 17 characters for this prefix.
 29    /// Use only letters, numbers, periods, hyphens, or underscores, and start and end the value with a
 30    /// letter or number.
 31    /// </remarks>
 4132    public string? InstanceName { get; set; }
 33
 34    /// <summary>
 35    /// The name of an environment variable to read the instance name from when <see cref="InstanceName"/>
 36    /// is not set. For example, set this to <c>HOSTNAME</c> to use the Kubernetes pod name (stable across
 37    /// restarts when running as a StatefulSet). When <see langword="null"/> or empty, no environment
 38    /// variable is read and a random name is generated instead.
 39    /// </summary>
 40    /// <remarks>
 41    /// The environment variable name is trimmed before lookup. The value it contains follows the same
 42    /// transport entity-name length constraints as <see cref="InstanceName"/>.
 43    /// </remarks>
 2244    public string? InstanceNameEnvironmentVariable { get; set; }
 45}