Table of Contents

Class SessionCleanupService

Namespace
JD.AI.Gateway.Services
Assembly
JD.AI.Gateway.dll

Background service that periodically scans for stale sessions and closes them. A session is considered stale when it has been inactive (no UpdatedAt change) for longer than the configured MaxInactiveAge.

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

Constructors

SessionCleanupService(SessionStore, IOptions<GatewayConfig>, ILogger<SessionCleanupService>)

public SessionCleanupService(SessionStore sessionStore, IOptions<GatewayConfig> config, ILogger<SessionCleanupService> log)

Parameters

sessionStore SessionStore
config IOptions<GatewayConfig>
log ILogger<SessionCleanupService>

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.