Added OnError event to MetaObjectLock (#1585)
* Added OnError event to MetaObjectLock * Updated event name
This commit is contained in:
@@ -9,6 +9,11 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
private readonly string identity;
|
||||
private T metaObjCache;
|
||||
|
||||
/// <summary>
|
||||
/// OnHttpError is called when there is a http operation error.
|
||||
/// </summary>
|
||||
public event Action<HttpOperationException> OnHttpError;
|
||||
|
||||
protected MetaObjectLock(IKubernetes client, string @namespace, string name, string identity)
|
||||
{
|
||||
this.client = client ?? throw new ArgumentNullException(nameof(client));
|
||||
@@ -47,8 +52,9 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
Interlocked.Exchange(ref metaObjCache, createdObj);
|
||||
return true;
|
||||
}
|
||||
catch (HttpOperationException)
|
||||
catch (HttpOperationException e)
|
||||
{
|
||||
OnHttpError?.Invoke(e);
|
||||
// ignore
|
||||
}
|
||||
|
||||
@@ -79,8 +85,9 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
Interlocked.Exchange(ref metaObjCache, replacedObj);
|
||||
return true;
|
||||
}
|
||||
catch (HttpOperationException)
|
||||
catch (HttpOperationException e)
|
||||
{
|
||||
OnHttpError?.Invoke(e);
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user