jspuij / RESTier

A turn-key library for building RESTful services
http://odata.github.io/RESTier
Other
2 stars 0 forks source link

RestierQueryExecutor and DefaultQueryExecutor have transient lifetime #18

Open jspuij opened 5 years ago

jspuij commented 5 years ago

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.

jspuij commented 5 years ago

Part of https://github.com/OData/RESTier/issues/629

jspuij commented 5 years ago

PArt of https://github.com/jspuij/RESTier/issues/13

robertmclaws commented 5 years ago

Let's make them Singletons and fix for v1.

jspuij commented 5 years ago

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.