using Febe.Core.Engine; namespace Febe.App; /// /// The recipe runner of the engine before the browser exists: the engine and its monitor are built at start-up (the /// interface shows them at once), the collection pipeline only when Chromium is up. The engine loop is started after /// is set, so a recipe never runs without it. /// public sealed class DeferredRecipeRunner : IRecipeRunner { private volatile IRecipeRunner? _target; /// The real runner (the collection pipeline's), once the browser is up. public IRecipeRunner? Target { get => _target; set => _target = value; } public Task RunAsync(RecipeRequest request, ISessionContext session, CancellationToken ct) => _target is { } target ? target.RunAsync(request, session, ct) : Task.FromResult(new RecipeOutcome(RecipeStatus.Cancelled, 0, 0, "Il browser non รจ ancora pronto.")); public Task RestAsync(CancellationToken ct) => _target?.RestAsync(ct) ?? Task.CompletedTask; /// The real runner's answer; before the browser is up nothing is known, and nothing is held back. public string? NotConfiguredReason(RecipeKind kind) => _target?.NotConfiguredReason(kind); }