-
-
Notifications
You must be signed in to change notification settings - Fork 835
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
Use ephemeral service info blocks for any lookups before the registry is built. #1220
Conversation
… 'OnlyIf' type callbacks will consume ephemeral service information.
Codecov Report
@@ Coverage Diff @@
## develop #1220 +/- ##
===========================================
+ Coverage 75.89% 76.10% +0.21%
===========================================
Files 189 189
Lines 4683 4721 +38
Branches 957 969 +12
===========================================
+ Hits 3554 3593 +39
+ Misses 674 669 -5
- Partials 455 459 +4
Continue to review full report at Codecov.
|
If the purpose is to resolve #1217 and related things, brainstorming test cases:
This seems like some sort of combinatoric data driven test could be done but I'm not sure how that'd work. Probably too many indirections to lambdas and things to make it intelligible long term. |
Thanks @tillig; I'll probably just create the additional tests directly. As you say, the setup for them is going to be a bit too varied. |
Added more tests based on your comments. We already have a |
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.
Minor test thing, otherwise I think this is a good solution to the problem. I can't think of a way to deal with it other than this and I've been sort of churning it around in my mind for a few days.
builder.RegisterGeneric(typeof(MultiServiceGeneric<>)).As(typeof(IService<>)).As(typeof(IService2<>)); | ||
builder.RegisterGeneric(typeof(MultiServiceGeneric<>)).As(typeof(IService<>)).IfNotRegistered(typeof(IService2<int>)); |
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.
I think this would be more clear if two different open generics were being registered. Regardless of whether IfNotRegistered
works, IService<>
will be a MultiServiceGeneric<>
.
I sometimes wonder if the fluent callback mechanism for registration is worth the trouble. |
I can see some of the benefit of the |
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.
🔏
I don't think we should change to collection-based registration necessarily, just sometimes the callbacks and the callbacks that call callbacks and the order of those callbacks seems... pretty complex for what actually ends up happening. |
This change constructs a temporary set of
ServiceRegistrationInfo
for calls toGetInitializedServiceInfo
that take place during the build callbacks that populate theDefaultRegisteredServicesTracker
.Marginal extra performance cost to
IfNotRegistered
calls at container build time to allocate a new set, and the overhead of evaluating sources multiple times, but once the tracker is marked asComplete
, the only extra cost is a single boolean flag check the first time we initialize aServiceRegistrationInfo
. No concurrency issues expected, because the Container Build process is always a single-threaded operation anyway.Fixes #1217. Also added a test for conditional registrations based on dynamic sources, and on service middleware.
Any suggestions of additional test cases would be most welcome.