Skip to content

Commit 541abb0

Browse files
authored
Added OnError event to MetaObjectLock (#1585)
* Added OnError event to MetaObjectLock * Updated event name
1 parent 722f21c commit 541abb0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ public abstract class MetaObjectLock<T> : ILock
99
private readonly string identity;
1010
private T metaObjCache;
1111

12+
/// <summary>
13+
/// OnHttpError is called when there is a http operation error.
14+
/// </summary>
15+
public event Action<HttpOperationException> OnHttpError;
16+
1217
protected MetaObjectLock(IKubernetes client, string @namespace, string name, string identity)
1318
{
1419
this.client = client ?? throw new ArgumentNullException(nameof(client));
@@ -47,8 +52,9 @@ public async Task<bool> CreateAsync(LeaderElectionRecord record, CancellationTok
4752
Interlocked.Exchange(ref metaObjCache, createdObj);
4853
return true;
4954
}
50-
catch (HttpOperationException)
55+
catch (HttpOperationException e)
5156
{
57+
OnHttpError?.Invoke(e);
5258
// ignore
5359
}
5460

@@ -79,8 +85,9 @@ public async Task<bool> UpdateAsync(LeaderElectionRecord record, CancellationTok
7985
Interlocked.Exchange(ref metaObjCache, replacedObj);
8086
return true;
8187
}
82-
catch (HttpOperationException)
88+
catch (HttpOperationException e)
8389
{
90+
OnHttpError?.Invoke(e);
8491
// ignore
8592
}
8693

0 commit comments

Comments
 (0)