Section navigation

Public classSealed ReaderManager<TReader>

Namespace
Rowles.LeanCorpus.Search.Searcher
Assembly
Rowles.LeanCorpus.dll

Owns an immutable, reference-counted reader and swaps in replacements produced by a caller-supplied refresh function.

public sealed class ReaderManager<TReader> : IDisposable where TReader : class, IDisposable

Type Parameters

TReader

The disposable reader type managed by this instance.

Inheritance
ReaderManager<TReader>
Implements

Public constructor ReaderManager(Func<TReader>, Func<TReader, TReader?>, TimeSpan?)

Initialises a reader manager and starts its background refresh loop.

Public property ConsecutiveRefreshFailures

Gets the number of consecutive failed refreshes.

Public property LastRefreshError

Gets the most recent refresh exception, or null when none has failed.

Public property LastRefreshErrorAt

Gets the UTC time at which the most recent refresh exception was recorded.

Public method Acquire()

Acquires the current reader and requires the caller to release it explicitly.

Public method AcquireLease()

Acquires the current reader until the returned lease is disposed.

Public method Dispose()

Stops refreshes and retires all readers.

Public method GetDiagnostics()

Gets current reader and refresh counters.

Public method MaybeRefresh()

Attempts one synchronous refresh and returns whether a replacement was published.

Public method MaybeRefreshAsync(CancellationToken)

Checks for a replacement asynchronously.

Public method Release(TReader)

Releases a reader acquired through Acquire().

Public method TryAcquire(Func<TReader, bool>, out ReaderLease<TReader>)

Acquires a reader matching the supplied predicate, or returns false when none is retained.

Public event RefreshFailed

Raised when the refresh factory fails.