dispose cts after call finish (#1128)
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
namespace k8s;
|
namespace k8s;
|
||||||
|
|
||||||
public partial class AbstractKubernetes : I{{name}}Operations
|
public partial class AbstractKubernetes : I{{name}}Operations
|
||||||
{
|
{
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
async Task<HttpOperationResponse{{GetReturnType operation "<>"}}> I{{name}}Operations.{{GetMethodName operation "WithHttpMessagesAsync"}}(
|
async Task<HttpOperationResponse{{GetReturnType operation "<>"}}> I{{name}}Operations.{{GetMethodName operation "WithHttpMessagesAsync"}}(
|
||||||
@@ -17,7 +17,7 @@ public partial class AbstractKubernetes : I{{name}}Operations
|
|||||||
IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders,
|
IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
|
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
|
||||||
cts.CancelAfter(HttpClientTimeout);
|
cts.CancelAfter(HttpClientTimeout);
|
||||||
{{#IfParamContains operation "watch"}}
|
{{#IfParamContains operation "watch"}}
|
||||||
if (watch == true)
|
if (watch == true)
|
||||||
@@ -58,13 +58,13 @@ public partial class AbstractKubernetes : I{{name}}Operations
|
|||||||
{{#IfParamDoesNotContain operation "body"}}
|
{{#IfParamDoesNotContain operation "body"}}
|
||||||
var httpResponse = await SendRequest<object>(url, HttpMethods.{{Method}}, customHeaders, null, cancellationToken);
|
var httpResponse = await SendRequest<object>(url, HttpMethods.{{Method}}, customHeaders, null, cancellationToken);
|
||||||
{{/IfParamDoesNotContain operation "body"}}
|
{{/IfParamDoesNotContain operation "body"}}
|
||||||
// Create Result
|
// Create Result
|
||||||
var httpRequest = httpResponse.RequestMessage;
|
var httpRequest = httpResponse.RequestMessage;
|
||||||
{{#IfReturnType operation "void"}}
|
{{#IfReturnType operation "void"}}
|
||||||
HttpOperationResponse result = new HttpOperationResponse() { Request = httpRequest, Response = httpResponse };
|
HttpOperationResponse result = new HttpOperationResponse() { Request = httpRequest, Response = httpResponse };
|
||||||
{{/IfReturnType operation "void"}}
|
{{/IfReturnType operation "void"}}
|
||||||
{{#IfReturnType operation "obj"}}
|
{{#IfReturnType operation "obj"}}
|
||||||
var result = await CreateResultAsync{{GetReturnType operation "<>"}}(
|
var result = await CreateResultAsync{{GetReturnType operation "<>"}}(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
httpResponse,
|
httpResponse,
|
||||||
{{#IfParamContains operation "watch"}}
|
{{#IfParamContains operation "watch"}}
|
||||||
|
|||||||
Reference in New Issue
Block a user