-
Notifications
You must be signed in to change notification settings - Fork 1
LNK-4430: Data Acquisition - Handle 429 Status #1378
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c17b363
Checkin
nvmLantana 717291c
Merge branch 'dev' into nvm/LNK-4430_Handle429QueryCase
nvmLantana fbe3d1d
Fix tests
nvmLantana 70dc512
Don't Count 429 as a Failure
nvmLantana a2581bc
Merge branch 'dev' into nvm/LNK-4430_Handle429QueryCase
nvmLantana 97b7cd9
ParseRetryAfter refactor and safety
nvmLantana 9f09f61
refactor
nvmLantana 0aa2a2e
refactor
nvmLantana 13f1306
final refactor
nvmLantana abbc318
Add More Tests
nvmLantana d398f5f
ExecutionDate filtering in query
nvmLantana 8797e9d
429 Set ExecutionDate for ALL of the facilities Pending, Ready, and F…
nvmLantana 90e4fed
changes after convo
nvmLantana 827e12e
Merge branch 'dev' into nvm/LNK-4430_Handle429QueryCase
nvmLantana 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 hidden or 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
7 changes: 7 additions & 0 deletions
7
DotNet/DataAcquisition.Domain/Application/Models/Exceptions/ProcessingDelayException.cs
This file contains hidden or 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,7 @@ | ||
| namespace LantanaGroup.Link.DataAcquisition.Domain.Application.Models.Exceptions | ||
| { | ||
| public class ProcessingDelayException : Exception | ||
| { | ||
| public ProcessingDelayException(string message) : base(message) { } | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
DotNet/DataAcquisition.Domain/Application/Models/Exceptions/TooManyRequestsException.cs
This file contains hidden or 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,14 @@ | ||
| using System; | ||
| using Hl7.Fhir.Rest; | ||
|
|
||
| namespace LantanaGroup.Link.DataAcquisition.Domain.Application.Models.Exceptions | ||
| { | ||
| public class TooManyRequestsException : FhirOperationException | ||
| { | ||
| public TimeSpan RetryAfter { get; } | ||
| public TooManyRequestsException(string message, TimeSpan retryAfter) : base(message, System.Net.HttpStatusCode.TooManyRequests) | ||
| { | ||
| RetryAfter = retryAfter; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
51 changes: 51 additions & 0 deletions
51
DotNet/DataAcquisition.Domain/Application/Services/FhirApi/Commands/FhirCommandUtils.cs
This file contains hidden or 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,51 @@ | ||
| using System.Net.Http.Headers; | ||
|
|
||
| namespace LantanaGroup.Link.DataAcquisition.Domain.Application.Services.FhirApi.Commands; | ||
|
|
||
| internal class HeaderCapturingHandler : DelegatingHandler | ||
| { | ||
| public HttpResponseHeaders? LastResponseHeaders { get; private set; } | ||
|
|
||
| protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
| { | ||
| var response = await base.SendAsync(request, cancellationToken); | ||
| LastResponseHeaders = response.Headers; | ||
| return response; | ||
| } | ||
| } | ||
|
|
||
| public static class FhirCommandUtils | ||
| { | ||
| public static TimeSpan ParseRetryAfter(HttpResponseHeaders? headers, TimeSpan defaultDelay = default) | ||
| { | ||
| defaultDelay = defaultDelay == default ? TimeSpan.FromSeconds(60) : defaultDelay; | ||
|
|
||
| if (headers == null || headers.RetryAfter == null) | ||
| { | ||
| return defaultDelay; | ||
| } | ||
|
|
||
| var retryValue = headers.RetryAfter; | ||
| TimeSpan delay; | ||
|
|
||
| if (retryValue.Delta.HasValue) | ||
| { | ||
| delay = retryValue.Delta.Value; | ||
| } | ||
| else if (retryValue.Date.HasValue) | ||
| { | ||
| delay = retryValue.Date.Value - DateTimeOffset.UtcNow; | ||
| } | ||
| else | ||
| { | ||
| return defaultDelay; | ||
| } | ||
|
|
||
| if (delay <= TimeSpan.Zero) | ||
| { | ||
| return defaultDelay; | ||
| } | ||
|
|
||
| return delay; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.