-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add startupable #16
base: main
Are you sure you want to change the base?
Add startupable #16
Conversation
Autofac support started, will continue netcore later |
Codecov Report
@@ Coverage Diff @@
## main #16 +/- ##
==========================================
- Coverage 78.59% 78.51% -0.09%
==========================================
Files 19 19
Lines 710 712 +2
==========================================
+ Hits 558 559 +1
- Misses 152 153 +1
Continue to review full report at Codecov.
|
@@ -25,6 +26,18 @@ public static class StartupExtension | |||
return rtn; | |||
} | |||
|
|||
public static IServiceProvider UseAgodaIoCStartupable(this IServiceProvider app) | |||
{ | |||
foreach (var startupable in app.GetServices<IStartupable>()) |
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.
Note: Not sure if GetServices returns null or an empty list.
Somedata = 0; | ||
} | ||
public int Somedata { get; set; } | ||
public void Start() |
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.
Ideally, it would be nice if the startup process could run asynchronously. I would expect that most of the implementation will communicate with other services etc. therefore it might be better to start returning a Task from the start.
if (startupable == null) | ||
throw new Exception( | ||
"No service found that inherit from IStartupable but UseAgodaIoCStartupable was called"); | ||
startupable.Start(); |
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.
maybe for a future iteration however it would be nice if you could specify the degree of parallelism.
For issue #15