Class BowireBenchmarkSchedulingHostedService
- Namespace
- Kuestenlogik.Bowire.Benchmarking
- Assembly
- Kuestenlogik.Bowire.Benchmarking.dll
Fires scheduled benchmarks (#232).
Holds no schedule state of its own: it re-reads the store on every tick, which is what makes a schedule survive a restart (the entry is on disk, not in memory) and also means an operator adding, pausing or deleting a schedule takes effect without a bounce.
A run is due when its next cron occurrence has passed since the last time this service looked. Comparing against the schedule's own last-run timestamp — rather than an in-memory timer — keeps a missed window (host asleep, deploy in progress) from silently swallowing the run, and keeps a restart from re-firing one that already happened.
public sealed class BowireBenchmarkSchedulingHostedService : BackgroundService, IHostedService, IDisposable
- Inheritance
-
BowireBenchmarkSchedulingHostedService
- Implements
- Inherited Members
Constructors
BowireBenchmarkSchedulingHostedService(BowireBenchmarkScheduleStore, IBowireBenchmarkProtocolResolver, ILogger<BowireBenchmarkSchedulingHostedService>, TimeSpan?)
Create the service.
public BowireBenchmarkSchedulingHostedService(BowireBenchmarkScheduleStore store, IBowireBenchmarkProtocolResolver protocols, ILogger<BowireBenchmarkSchedulingHostedService> logger, TimeSpan? tickInterval = null)
Parameters
storeBowireBenchmarkScheduleStoreWhere schedules and their history live.
protocolsIBowireBenchmarkProtocolResolverResolves a protocol plugin by id at firing time.
loggerILogger<BowireBenchmarkSchedulingHostedService>Diagnostics.
tickIntervalTimeSpan?How often to look for due schedules; defaults to 30s.
Fields
ActivitySource
ActivitySource scheduled runs are reported on (#29 / #102).
public static readonly ActivitySource ActivitySource
Field Value
Methods
ExecuteAsync(CancellationToken)
protected override Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationToken
Returns
RunAsync(BowireBenchmarkSchedule, DateTime, string, CancellationToken)
Execute one schedule now and record the result. triggeredBy
distinguishes a cron firing from an operator pressing Run.
public Task<BowireBenchmarkScheduleRun?> RunAsync(BowireBenchmarkSchedule schedule, DateTime startedAtUtc, string triggeredBy, CancellationToken ct = default)
Parameters
scheduleBowireBenchmarkSchedulestartedAtUtcDateTimetriggeredBystringctCancellationToken
Returns
TickAsync(DateTime, CancellationToken)
One scheduler pass: run everything that came due at or before
nowUtc. Public so a test can drive it directly
rather than waiting on wall-clock ticks.
public Task<int> TickAsync(DateTime nowUtc, CancellationToken ct = default)
Parameters
nowUtcDateTimectCancellationToken