-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve dates when deserializing job message from Run Service (#3269)
* Preserve dates when deserializing job message from Run Service * Preserve dates when deserializing job message from "Actions Run Service"
- Loading branch information
1 parent
04b07b6
commit 18803bd
Showing
4 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GitHub.Services.Common; | ||
using GitHub.Services.Common.Diagnostics; | ||
using GitHub.Services.WebApi; | ||
using Newtonsoft.Json; | ||
|
||
namespace GitHub.DistributedTask.WebApi | ||
{ | ||
[ResourceArea(TaskResourceIds.AreaId)] | ||
public class ActionsRunServerHttpClient : TaskAgentHttpClient | ||
{ | ||
private static readonly JsonSerializerSettings s_serializerSettings; | ||
|
||
static ActionsRunServerHttpClient() | ||
{ | ||
s_serializerSettings = new VssJsonMediaTypeFormatter().SerializerSettings; | ||
s_serializerSettings.DateParseHandling = DateParseHandling.None; | ||
s_serializerSettings.FloatParseHandling = FloatParseHandling.Double; | ||
} | ||
|
||
public ActionsRunServerHttpClient( | ||
Uri baseUrl, | ||
VssCredentials credentials) | ||
: base(baseUrl, credentials) | ||
{ | ||
} | ||
|
||
public ActionsRunServerHttpClient( | ||
Uri baseUrl, | ||
VssCredentials credentials, | ||
VssHttpRequestSettings settings) | ||
: base(baseUrl, credentials, settings) | ||
{ | ||
} | ||
|
||
public ActionsRunServerHttpClient( | ||
Uri baseUrl, | ||
VssCredentials credentials, | ||
params DelegatingHandler[] handlers) | ||
: base(baseUrl, credentials, handlers) | ||
{ | ||
} | ||
|
||
public ActionsRunServerHttpClient( | ||
Uri baseUrl, | ||
VssCredentials credentials, | ||
VssHttpRequestSettings settings, | ||
params DelegatingHandler[] handlers) | ||
: base(baseUrl, credentials, settings, handlers) | ||
{ | ||
} | ||
|
||
public ActionsRunServerHttpClient( | ||
Uri baseUrl, | ||
HttpMessageHandler pipeline, | ||
Boolean disposeHandler) | ||
: base(baseUrl, pipeline, disposeHandler) | ||
{ | ||
} | ||
|
||
public Task<Pipelines.AgentJobRequestMessage> GetJobMessageAsync( | ||
string messageId, | ||
object userState = null, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
HttpMethod httpMethod = new HttpMethod("GET"); | ||
Guid locationId = new Guid("25adab70-1379-4186-be8e-b643061ebe3a"); | ||
object routeValues = new { messageId = messageId }; | ||
|
||
return SendAsync<Pipelines.AgentJobRequestMessage>( | ||
httpMethod, | ||
locationId, | ||
routeValues: routeValues, | ||
version: new ApiResourceVersion(6.0, 1), | ||
userState: userState, | ||
cancellationToken: cancellationToken); | ||
} | ||
|
||
protected override async Task<T> ReadJsonContentAsync<T>(HttpResponseMessage response, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
var json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
return JsonConvert.DeserializeObject<T>(json, s_serializerSettings); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters