Files
csharp/gen/KubernetesWatchGenerator/Kubernetes.Watch.cs.template
Frederik Carlier bc1cb6205c Watcher: notify the caller when the server closes the connection (#184)
* Watcher: Add onClosed event and callback

* Update the code generators to accept the onClose callback

* Re-generate API

* Update unit tests

* Fix unit test

* Watcher fixes/improvements:
- Run Task.Yield at the beginning to make sure we're running async
- Set Watching = false before invoking OnClosed, to make sure the callers see a consistent state.
2018-06-27 14:38:28 -07:00

37 lines
1.4 KiB
Plaintext

using k8s.Models;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace k8s
{
public partial class Kubernetes
{
{{#.}}
/// <inheritdoc>
public Task<Watcher<{{GetClassName operation}}>> {{GetMethodName operation}}(
{{#operation.actualParameters}}
{{#isRequired}}
{{GetDotNetType type name isRequired}} {{GetDotNetName name}},
{{/isRequired}}
{{/operation.actualParameters}}
{{#operation.actualParameters}}
{{^isRequired}}
{{GetDotNetType .}} {{GetDotNetName .}} = null,
{{/isRequired}}
{{/operation.actualParameters}}
Dictionary<string, List<string>> customHeaders = null,
Action<WatchEventType, {{GetClassName operation}}> onEvent = null,
Action<Exception> onError = null,
Action onClosed = null,
CancellationToken cancellationToken = default(CancellationToken))
{
string path = $"{{GetPathExpression .}}";
return WatchObjectAsync<{{GetClassName operation}}>(path: path, @continue: @continue, fieldSelector: fieldSelector, includeUninitialized: includeUninitialized, labelSelector: labelSelector, limit: limit, pretty: pretty, timeoutSeconds: timeoutSeconds, resourceVersion: resourceVersion, customHeaders: customHeaders, onEvent: onEvent, onError: onError, onClosed: onClosed, cancellationToken: cancellationToken);
}
{{/.}}
}
}