-
Notifications
You must be signed in to change notification settings - Fork 6
Bring back ProjectionFactory #68
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
Conversation
Also use IServiceScopeFactory instead of IServiceProvider in ProjectionProcessor to make it more clear that we are only creating scopes
If my PR #66 gets merged I could create some functional tests to show how the IProjectionFactory could be used. |
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
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.
@agehrke Please update the change log
try | ||
{ | ||
await projection | ||
.InitializeAsync( | ||
events.Key, | ||
eventStreamId, |
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 can see this as something slightly more costly than just passing in the events.Key
, but I don't think it matters
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.
Actually no. Previously there was an implicit conversion from StreamId
to EventStreamId
. Now I'm just explicit about that conversion.
I have updated changelog.md |
Bring back
ProjectionFactory
but with a slightly different interface. This factory would allow consumers to make additional "initialization" of projections:A few things to note:
The default implementation
DefaultProjectionFactory
just resolvesTProjection
throughIServiceProvider
. To allow aIProjectionFactory
to create instances that consumes scoped resources, the type is registered as transient.One could argue that the
IProjection.InitializeAsync
method could be invoked by theDefaultProjectionFactory
as that method is somewhat an async constructor.Other changes
I have also changed
ProjectionProcessor
to useIServiceScopeFactory
instead ofIServiceProvider
which, IMO, make it more clear that we are only creating scopes.