-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix allowedVmSizes #210
Fix allowedVmSizes #210
Conversation
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.
The technique used here affords a way to delay the start of a subsequent background service in order to ensure that all needed initialization has been performed.
When using the IOptions
pattern, its an anti-pattern to hold onto IConfiguration
unless your code is actively changing configuration values.
My honest opinion is that DoOnceAtStartUpService
is an anti-pattern by itself, and the operations performed here should be called from either Program.cs or Startup.cs, but I'm not going to litigate that here.
I'm not quite following how you could use .Wait() in the Startup ConfigureServices method to hold off the batchscheduler singleton until after DoOnceAtStartUpService has run. I don't have enough experience with IOptions, why is it an anti-pattern to hold onto IConfiguration. It looks like one of the first examples in Microsoft docs is doing just that: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-7.0#bind-hierarchical-configuration |
That first example is explicitly NOT the dependency injection example. The second example is explicitly is. The idea with the |
d609c0c
to
7d68c9a
Compare
namespace TesApi.Web | ||
{ | ||
/// <summary> | ||
/// Hosted service that executes one-time set up tasks at start up. |
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.
should fix this comment to be relevant too
private Task firstTask; | ||
|
||
/// <summary> | ||
/// Hosted service that executes one-time set-up tasks at start up. |
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.
should fix this comment to be relevant too
AllowedVmSizes isn't currently working after some recent refactor. The allowed vm list was being set up in the constructor before the DoOnceAtStartUpService service has had a chance to run and parse the file.