-
Notifications
You must be signed in to change notification settings - Fork 956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve dates when deserializing job message from Run Service #3269
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -9,13 +9,23 @@ | |||
using GitHub.Services.Common; | ||||
using GitHub.Services.OAuth; | ||||
using GitHub.Services.WebApi; | ||||
using Newtonsoft.Json; | ||||
ericsciple marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
using Sdk.RSWebApi.Contracts; | ||||
using Sdk.WebApi.WebApi; | ||||
|
||||
namespace GitHub.Actions.RunService.WebApi | ||||
{ | ||||
public class RunServiceHttpClient : RawHttpClientBase | ||||
{ | ||||
private static readonly JsonSerializerSettings s_serializerSettings; | ||||
|
||||
static RunServiceHttpClient() | ||||
{ | ||||
s_serializerSettings = new VssJsonMediaTypeFormatter().SerializerSettings; | ||||
s_serializerSettings.DateParseHandling = DateParseHandling.None; | ||||
s_serializerSettings.FloatParseHandling = FloatParseHandling.Double; | ||||
} | ||||
|
||||
public RunServiceHttpClient( | ||||
Uri baseUrl, | ||||
VssOAuthCredential credentials) | ||||
|
@@ -174,5 +184,11 @@ public async Task<RenewJobResponse> RenewJobAsync( | |||
throw new Exception($"Failed to renew job: {result.Error}"); | ||||
} | ||||
} | ||||
|
||||
protected override async Task<T> ReadJsonContentAsync<T>(HttpResponseMessage response, CancellationToken cancellationToken = default(CancellationToken)) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a virtual method on
|
||||
{ | ||||
var json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||||
return JsonConvert.DeserializeObject<T>(json, s_serializerSettings); | ||||
} | ||||
} | ||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to isolate the change to this one call since this flow is controlled by a feature flag