Class CachingConnectionResolver
- Namespace
- Cratis.Arc.Connections
- Assembly
- Cratis.Arc.Core.dll
Represents an ICachingConnectionResolver that keeps resolved connections in memory.
[IgnoreConvention]
public class CachingConnectionResolver : ICachingConnectionResolver, IConnectionResolver
- Inheritance
-
CachingConnectionResolver
- Implements
- Inherited Members
- Extension Methods
Remarks
Entries are keyed by the request — storage, purpose and scope — never by credentials, and are kept until the ExpiresAt the resolver gave, less a minute of margin, or for the configured duration when it gave none. Concurrent requests for the same key share one resolution. A failed resolution is not kept.
Constructors
CachingConnectionResolver(IConnectionResolver, TimeSpan, TimeProvider)
Represents an ICachingConnectionResolver that keeps resolved connections in memory.
public CachingConnectionResolver(IConnectionResolver inner, TimeSpan cacheDuration, TimeProvider timeProvider)
Parameters
innerIConnectionResolverThe IConnectionResolver to resolve through.
cacheDurationTimeSpanHow long to keep a resolution without an expiry.
timeProviderTimeProviderThe TimeProvider for the current time.
Remarks
Entries are keyed by the request — storage, purpose and scope — never by credentials, and are kept until the ExpiresAt the resolver gave, less a minute of margin, or for the configured duration when it gave none. Concurrent requests for the same key share one resolution. A failed resolution is not kept.
Fields
ExpiryMargin
The margin before ExpiresAt at which a resolution is renewed.
public static readonly TimeSpan ExpiryMargin
Field Value
Methods
Invalidate(ConnectionRequest)
Forget the resolved connection for a request, so the next resolution asks the resolvers again.
public void Invalidate(ConnectionRequest request)
Parameters
requestConnectionRequestThe ConnectionRequest to forget.
Remarks
Call this when a connection fails to authenticate, so rotated credentials are picked up.
Resolve(ConnectionRequest, CancellationToken)
Resolve a connection.
public Task<ResolvedConnection> Resolve(ConnectionRequest request, CancellationToken cancellationToken = default)
Parameters
requestConnectionRequestThe ConnectionRequest to resolve for.
cancellationTokenCancellationTokenOptional CancellationToken.
Returns
- Task<ResolvedConnection>
The ResolvedConnection. Use Unchanged to keep the configured connection.