using System;
namespace StellaOps.Notify.Worker;
public sealed class NotifyWorkerOptions
{
///
/// Worker identifier prefix; defaults to machine name.
///
public string? WorkerId { get; set; }
///
/// Number of messages to lease per iteration.
///
public int LeaseBatchSize { get; set; } = 16;
///
/// Duration a lease remains active before it becomes eligible for claim.
///
public TimeSpan LeaseDuration { get; set; } = TimeSpan.FromSeconds(30);
///
/// Delay applied when no work is available.
///
public TimeSpan IdleDelay { get; set; } = TimeSpan.FromMilliseconds(250);
///
/// Maximum number of event leases processed concurrently.
///
public int MaxConcurrency { get; set; } = 4;
///
/// Maximum number of consecutive failures before the worker delays.
///
public int FailureBackoffThreshold { get; set; } = 3;
///
/// Delay applied when the failure threshold is reached.
///
public TimeSpan FailureBackoffDelay { get; set; } = TimeSpan.FromSeconds(5);
internal string ResolveWorkerId()
{
if (!string.IsNullOrWhiteSpace(WorkerId))
{
return WorkerId!;
}
var host = Environment.MachineName;
return $"{host}-{Guid.NewGuid():n}";
}
}