Class FailureThresholdManager<T, T2>
Simple threshold manager, tracks failed jobs and executes callback if budget is exhausted. The callback is executed on every failure reported, as long as the failure budget is not expanded, or failed items removed from the internal collection using the Success method.
Inherited Members
Namespace: Cognite.Extractor.Common
Assembly: Cognite.Common.dll
Syntax
public class FailureThresholdManager<T, T2> where T : IComparable
Type Parameters
| Name | Description |
|---|---|
| T | |
| T2 |
Constructors
| Edit this page View SourceFailureThresholdManager(double, long, Action<IReadOnlyDictionary<T, T2>>)
Constructor
Declaration
public FailureThresholdManager(double thresholdPercentage, long totalJobCount, Action<IReadOnlyDictionary<T, T2>> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| double | thresholdPercentage | Threshold for failed jobs, %**,* |
| long | totalJobCount | Total number of jobs |
| Action<IReadOnlyDictionary<T, T2>> | callback | Callback method for when the threshold is exceeded |
Properties
| Edit this page View SourceFailedJobs
Get failed jobs
Declaration
public IReadOnlyDictionary<T, T2> FailedJobs { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<T, T2> |
RemainingBudget
Remaining budget for failed jobs
Declaration
public long RemainingBudget { get; }
Property Value
| Type | Description |
|---|---|
| long |
ThresholdPercentage
Threshold for failed jobs, %**,*
Declaration
public double ThresholdPercentage { get; }
Property Value
| Type | Description |
|---|---|
| double |
TotalJobCount
Total number of jobs
Declaration
public long TotalJobCount { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceFailed(T, T2)
Adds job to failed items, checks if the failure budget has been exhausted. The value is overwritten in the case the job had previously failed.
Declaration
public void Failed(T job, T2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | job | Job Id |
| T2 | value | Custom value for the failed job |
Success(T)
Removes job from failed items. This method does not check the threshold, no callback will happen.
Declaration
public bool Success(T job)
Parameters
| Type | Name | Description |
|---|---|---|
| T | job | Job Id |
Returns
| Type | Description |
|---|---|
| bool | Removal operation success status |
UpdateBudget(double, long, bool)
Updates parameters for calculating the failure budget
Declaration
public void UpdateBudget(double thresholdPercentage, long totalJobCount, bool validate = true)
Parameters
| Type | Name | Description |
|---|---|---|
| double | thresholdPercentage | Threshold for failed jobs, %**,* |
| long | totalJobCount | Total number of jobs |
| bool | validate | Check if the updated failure budget is already exhausted |