ThrottleTracker
- Namespace:
PPDS.Dataverse.Resilience - Assembly:
PPDS.Dataverse - Kind: Class
- Implements:
IThrottleTracker
Summary
Tracks throttle state for connections using a thread-safe concurrent dictionary.
Members
Constructors
ThrottleTracker(ILogger<ThrottleTracker> logger)
ThrottleTracker(ILogger<ThrottleTracker> logger)
Initializes a new instance of the PPDS.Dataverse.Resilience.ThrottleTracker class.
- Param
logger: Logger instance.
Methods
ClearThrottle
void ClearThrottle(string connectionName)
Clears throttle state for a connection.
- Param
connectionName: The connection to clear.
GetShortestExpiry
TimeSpan GetShortestExpiry()
Gets the shortest time until any throttled connection expires.
Returns System.TimeSpan.Zero if no connections are throttled.
- Returns: The shortest time until a throttle expires, or
System.TimeSpan.Zeroif none are throttled.
GetThrottleExpiry
Nullable<DateTime> GetThrottleExpiry(string connectionName)
Gets when a connection's throttle expires.
-
Param
connectionName: The connection to check. -
Returns: The expiry time, or null if not throttled.
IsThrottled
bool IsThrottled(string connectionName)
Checks if a connection is currently throttled.
-
Param
connectionName: The connection to check. -
Returns: True if the connection is throttled.
RecordThrottle
void RecordThrottle(string connectionName, TimeSpan retryAfter)
Records a throttle event for a connection.
-
Param
connectionName: The connection that was throttled. -
Param
retryAfter: How long to wait before retrying.
Properties
ThrottledConnectionCount
int ThrottledConnectionCount { get; }
Gets the number of currently throttled connections.
ThrottledConnections
IReadOnlyCollection<string> ThrottledConnections { get; }
Gets the names of all currently throttled connections.
TotalBackoffTime
TimeSpan TotalBackoffTime { get; }
Gets the total backoff time accumulated from all throttle events. This represents the sum of all RetryAfter durations, not actual time spent waiting.
TotalThrottleEvents
long TotalThrottleEvents { get; }
Gets the total number of throttle events recorded.