Path: redb-route/redb.Route/Fluent/TimerDsl.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Fluent/TimerDsl.cs ---- using System.Text; using redb.Route.Abstractions; namespace redb.Route; /// /// Fluent entry point for Timer consumer endpoints. /// /// .From(Timer.Every("heartbeat").Period(5000).Delay(1000)) /// .From(Timer.Once("init")) /// /// public static class TimerDsl { /// Create a named repeating timer. public static TimerBuilder Every(string name) => new(name); /// Create a timer that fires once (repeatCount=1). public static TimerBuilder Once(string name) => new TimerBuilder(name).RepeatCount(1); } /// Fluent builder for Timer endpoint URIs. public sealed class TimerBuilder { private readonly string _name; private string? _period; private string? _delay; private string? _repeatCount; internal TimerBuilder(string name) { ArgumentException.ThrowIfNullOrWhiteSpace(name); _name = name; } /// Interval between ticks in milliseconds. Default 1000. public TimerBuilder Period(int ms) { _period = ms.ToString(); return this; } /// Interval from an expression. public TimerBuilder Period(IExpression ms) { _period = ms.ToTemplateString(); return this; } /// Initial delay before first tick in milliseconds. public TimerBuilder Delay(int ms) { _delay = ms.ToString(); return this; } /// Initial delay from an expression. public TimerBuilder Delay(IExpression ms) { _delay = ms.ToTemplateString(); return this; } /// Number of times to fire. Default unlimited (0). public TimerBuilder RepeatCount(int count) { _repeatCount = count.ToString(); return this; } /// Repeat count from an expression. public TimerBuilder RepeatCount(IExpression count) { _repeatCount = count.ToTemplateString(); return this; } public string Build() { var sb = new StringBuilder(); sb.Append("timer:"); sb.Append(_name); var sep = '?'; void AppendIf(string key, string? v) { if (v != null) { sb.Append(sep); sb.Append(key); sb.Append('='); sb.Append(v); sep = '&'; } } AppendIf("period", _period); AppendIf("delay", _delay); AppendIf("repeatCount", _repeatCount); return sb.ToString(); } public static implicit operator string(TimerBuilder b) => b.Build(); public override string ToString() => Build(); }