-
Notifications
You must be signed in to change notification settings - Fork 641
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
Report services are not using Blob storage SDK classes anymore. #8484
Conversation
Blob storage resolution to be used by report services was moved to the DI container. Async refresh in CloudDownloadCountService.
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.
@@ -19,7 +19,7 @@ public CloudDownloadCountServiceRefreshJob(TimeSpan interval, CloudDownloadCount | |||
|
|||
public override Task Execute() | |||
{ | |||
return new Task(_downloadCountService.Refresh); | |||
return _downloadCountService.Refresh(); |
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.
Can we make sure that all async method names have an Async
suffix? Or would that be a huge change?
Also, please add an await
here. See: https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#prefer-asyncawait-over-directly-returning-task
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.
Unfortunately, our NuGetJobCoordinator
complains if that Execute
method returns a started task, so we have to wrap it in a new Task()
, updated the code.
private static Task CreateWrappingContinuingTask(Task originalTask, Action<Task> continuationTask, TaskContinuationOptions options) | |
{ | |
var continuation = originalTask.ContinueWith(continuationTask, options); | |
var wrapper = new Task(() => | |
{ | |
if (originalTask.Status == TaskStatus.WaitingForActivation || originalTask.Status == TaskStatus.Created) | |
{ | |
originalTask.Start(); | |
} | |
continuation.Wait(); | |
}); | |
return wrapper; | |
} | |
} |
(line 53)
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.
This is awesome!! 🥇
Report services were using Storage SDK classes directly instead of our wrappers around them. To centralize blob storage access code this change makes them use
ICloudBlobClient
.Duplicated code that switches between the primary and alternate source for stats was removed from individual services and moved into DI container. A registration of
ICloudBlobClient
keyed asBindingKeys.FeatureFlaggedStatisticsKey
resolves to a blob client that points to the proper storage account. Services are supposed to requestFunc<ICloudBlobClient>
from the DI container that will provide proper client on each individual call.A
SimpleCloudBlobExtensions
class was introduced to close the gap betweenCloudBlockBlobReference
class provided by the storage SDK andCloudBlobWrapper
in our code (specifically, our wrapper lacks equivalent ofDownloadTextAsync
).Additionally, report services did a
.ExistAsync()
checks before accessing the blob contents, causing unnecessary network round trip. More helpers were added toSimpleCloudBlobExtensions
to handle missing blobs gracefully on content retrieval instead, saving one HTTP request on each report content access.Lastly,
CloudDownloadCountService
was made async to accommodate for async-onlyISimpleCloudBlob
.