Table of Contents

Class RemoteConfigPoller

Namespace
JD.AI.Core.Config
Assembly
JD.AI.Core.dll

Periodically polls IRemoteConfigSource instances for changes and invokes a callback when new configuration is detected. Falls back to local config when remote sources are unavailable.

public sealed class RemoteConfigPoller : IDisposable
Inheritance
RemoteConfigPoller
Implements
Inherited Members

Constructors

RemoteConfigPoller(IEnumerable<IRemoteConfigSource>, Func<string, string, Task>, ILogger?, TimeSpan?)

public RemoteConfigPoller(IEnumerable<IRemoteConfigSource> sources, Func<string, string, Task> onConfigChanged, ILogger? logger = null, TimeSpan? pollInterval = null)

Parameters

sources IEnumerable<IRemoteConfigSource>

Remote config sources to poll.

onConfigChanged Func<string, string, Task>

Callback invoked when config changes. Receives (sourceName, newContent).

logger ILogger

Optional logger.

pollInterval TimeSpan?

How often to poll. Defaults to 30 seconds.

Properties

IsRunning

Whether the poller is actively running.

public bool IsRunning { get; }

Property Value

bool

SourceCount

Number of registered config sources.

public int SourceCount { get; }

Property Value

int

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

PollOnceAsync(CancellationToken)

Performs a single poll cycle across all sources. Useful for testing or for on-demand refresh.

public Task PollOnceAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

Start()

Starts the polling loop.

public void Start()