Table of Contents

Class DotNetDllBridgeWarmupHostedService

Namespace
Virtufin.WorkManager.Services
Assembly
Virtufin.WorkManager.dll

Hosted service that eagerly warms up the DotNetDll engine's CoreCLR bridge on startup (Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap.EnsureInitialized()), so the one-time bootstrap cost is paid before this pod is reported Ready rather than on a live worker's CreateWorker call.

Why this matters: under NativeAOT, loading a JIT-compiled worker DLL requires bootstrapping a secondary CoreCLR runtime via libhostfxr the first time any pod does this in its process lifetime. That cost has been observed live to take tens of seconds -- far longer than Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap's own documented ~200-500ms expectation -- comfortably busting the API Gateway's flat, 30-second deadline on forwarded dynamic-dispatch calls. Paying this cost during startup instead removes it from the request path entirely.

Kestrel readiness is gated via DotNetDllBridgeWarmupHealthCheck: Unhealthy while warmup is in progress, Healthy once it completes (whether it succeeded or failed -- see FailWarmup(Exception)).

public sealed class DotNetDllBridgeWarmupHostedService : BackgroundService, IHostedService, IDisposable
Inheritance
DotNetDllBridgeWarmupHostedService
Implements
Inherited Members

Constructors

DotNetDllBridgeWarmupHostedService(IDotNetDllBridgeWarmup, DotNetDllBridgeWarmupState, ILogger<DotNetDllBridgeWarmupHostedService>)

public DotNetDllBridgeWarmupHostedService(IDotNetDllBridgeWarmup warmup, DotNetDllBridgeWarmupState warmupState, ILogger<DotNetDllBridgeWarmupHostedService> logger)

Parameters

warmup IDotNetDllBridgeWarmup
warmupState DotNetDllBridgeWarmupState
logger ILogger<DotNetDllBridgeWarmupHostedService>

Methods

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

protected override Task ExecuteAsync(CancellationToken stoppingToken)

Parameters

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.