
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
TReaderThe disposable reader type managed by this instance.
- Inheritance
-
ReaderManager<TReader>
- Implements
ReaderManager(Func<TReader>, Func<TReader, TReader?>, TimeSpan?)
Initialises a reader manager and starts its background refresh loop.
ConsecutiveRefreshFailures
Gets the number of consecutive failed refreshes.
LastRefreshError
Gets the most recent refresh exception, or null when none has failed.
LastRefreshErrorAt
Gets the UTC time at which the most recent refresh exception was recorded.
Acquire()
Acquires the current reader and requires the caller to release it explicitly.
AcquireLease()
Acquires the current reader until the returned lease is disposed.
Dispose()
Stops refreshes and retires all readers.
GetDiagnostics()
Gets current reader and refresh counters.
MaybeRefresh()
Attempts one synchronous refresh and returns whether a replacement was published.
MaybeRefreshAsync(CancellationToken)
Checks for a replacement asynchronously.
Release(TReader)
Releases a reader acquired through Acquire().
TryAcquire(Func<TReader, bool>, out ReaderLease<TReader>)
Acquires a reader matching the supplied predicate, or returns false when none is retained.
RefreshFailed
Raised when the refresh factory fails.