public async Task <IActivateJobsResponse> SendActivateRequest(ActivateJobsRequest request, CancellationToken?cancelationToken = null) { using (var stream = client.ActivateJobs(request)) { var responseStream = stream.ResponseStream; if (await MoveNext(responseStream, cancelationToken)) { var response = responseStream.Current; return(new Responses.ActivateJobsResponses(response)); } // empty response return(new Responses.ActivateJobsResponses()); } }
public async Task SendActivateRequest(ActivateJobsRequest request, ConsumeJob consumer, DateTime?requestTimeout = null, CancellationToken?cancellationToken = null) { var activateRequestTimeout = requestTimeout ?? CalculateRequestTimeout(request); using (var stream = client.ActivateJobs(request, deadline: activateRequestTimeout)) { var responseStream = stream.ResponseStream; while (await MoveNext(responseStream, cancellationToken)) { var currentResponse = responseStream.Current; var response = new ActivateJobsResponses(currentResponse); await consumer.Invoke(response); } } }
public async Task <IActivateJobsResponse> SendActivateRequest(ActivateJobsRequest request, DateTime?requestTimeout = null, CancellationToken?cancelationToken = null) { DateTime activateRequestTimeout = requestTimeout ?? CalculateRequestTimeout(request); using (var stream = client.ActivateJobs(request, deadline: activateRequestTimeout)) { var responseStream = stream.ResponseStream; if (await MoveNext(responseStream, cancelationToken)) { var response = responseStream.Current; return(new ActivateJobsResponses(response)); } // empty response return(new ActivateJobsResponses()); } }
public async Task <IActivateJobsResponse> SendActivateRequest(ActivateJobsRequest request, CancellationToken?cancelationToken = null) { // we need a higher request deadline then the long polling request timeout var requestTimeout = request.RequestTimeout <= 0 ? 10 : (request.RequestTimeout / 1000) + 10; using (var stream = client.ActivateJobs(request, deadline: DateTime.UtcNow.AddSeconds(requestTimeout))) { var responseStream = stream.ResponseStream; if (await MoveNext(responseStream, cancelationToken)) { var response = responseStream.Current; return(new Responses.ActivateJobsResponses(response)); } // empty response return(new Responses.ActivateJobsResponses()); } }