Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add startupable #16

wants to merge 2 commits into from

Conversation

dicko2
Copy link
Contributor

@dicko2 dicko2 commented Mar 6, 2022

For issue #15

@dicko2
Copy link
Contributor Author

dicko2 commented Mar 6, 2022

Autofac support started, will continue netcore later

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2022

Codecov Report

Merging #16 (fd24541) into main (038711f) will decrease coverage by 0.08%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/Agoda.IoC.Core/RegistrationContext.cs 89.34% <50.00%> (-0.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 038711f...fd24541. Read the comment docs.

@@ -25,6 +26,18 @@ public static class StartupExtension
return rtn;
}

public static IServiceProvider UseAgodaIoCStartupable(this IServiceProvider app)
{
foreach (var startupable in app.GetServices<IStartupable>())

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()

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();

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants