/// <summary> /// Removes a callback for a healthcheck /// </summary> /// <param name="healthCheckName">The name of the healthcheck the callback is associated with</param> /// <param name="status">The status the callback is for</param> /// <remarks>If no health callback exists, no error is thrown</remarks> public void RemoveCallback(string healthCheckName, HealthMonitorStatus status) { _callbacks.TryRemove(CallbackName(healthCheckName, status), out var _); }
private string CallbackName(string healthCheckName, HealthMonitorStatus status) { return($"{healthCheckName}:{status}"); }
/// <summary> /// Add a callback for a health check /// </summary> /// <param name="healthCheckName">The name of the healthcheck</param> /// <param name="status">The status the health check should be in</param> /// <param name="callback">The callback</param> /// <remarks>If no health check exists with the name, no error is thrown. The callback is just never called</remarks> public void AddCallback(string healthCheckName, HealthMonitorStatus status, Func <HealthMonitorResult, Task> callback) { _callbacks.AddOrUpdate(CallbackName(healthCheckName, status), callback, (k, v) => callback); }