Open jspuij opened 5 years ago
Let's make them Singletons and fix for v1.
I've found many more and I feel it's a fundamental choice and maybe better for V2. Either we make the entire pipeline stateless, every handling class singleton and store request scoped state into a context, or we allow classes in the pipeline to store local state for the request and allocate a new set of objects for every request.
Propose to hold off and do it correctly for every class.
These classes are added to the DI container without a lifetime, which in effect makes them transient. This leads to instantiation for every request which is unnecessary, because they don't have any local state during the request.
If we would give them Singleton lifetime as the rest, we could use constructor arguments. Otherwise we will need to create a factory for these types.