Table of Contents

Class UpdateService

Namespace
JD.AI.Daemon.Services
Assembly
JD.AI.Daemon.dll

Hosted service that periodically checks for daemon updates and orchestrates graceful update application.

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

Constructors

UpdateService(IOptions<UpdateConfig>, UpdateChecker, IEventBus, IHostApplicationLifetime, ILogger<UpdateService>)

public UpdateService(IOptions<UpdateConfig> config, UpdateChecker checker, IEventBus events, IHostApplicationLifetime lifetime, ILogger<UpdateService> logger)

Parameters

config IOptions<UpdateConfig>
checker UpdateChecker
events IEventBus
lifetime IHostApplicationLifetime
logger ILogger<UpdateService>

Properties

IsDraining

Whether the service is currently draining for an update.

public bool IsDraining { get; }

Property Value

bool

PendingUpdate

The last detected pending update, if any.

public UpdateInfo? PendingUpdate { get; }

Property Value

UpdateInfo

Methods

ApplyUpdateAsync(CancellationToken)

Applies a pending update: drains agents, runs dotnet tool update, restarts the service. Can be called manually by the CLI update command.

public Task ApplyUpdateAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

CheckAllToolsAsync(CancellationToken)

Checks all installed JD.AI tools for updates and returns a structured plan.

public Task<AllToolsUpdatePlan> CheckAllToolsAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<AllToolsUpdatePlan>

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.

UpdateAllToolsAsync(CancellationToken)

Applies updates to all installed JD.AI tools: drains agents, updates each tool, then restarts the daemon. Can be called manually via the CLI update command.

public Task UpdateAllToolsAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task