I am migrating an existing service to be multi-tennated, and in the process will need to rewire all my dependencies, and mange their reuse scope to be
I have already migrated our Azure workerroles which runs 7 worker processes in parallel, by registering all the ‘global’ singleton components in the main container, and creating 7 child containers and registering the tenant-sensitive singletons in each child container. So that each worker has its own copies of the components it needs without interfering with other worker dependencies. So have some experience using child containers for that. But this does not use the scope
Request of course.
Now, I want to migrate my webrole, which currently has everything as singletons in the main container.
I am thinking, for the web service, that I will put all the global components as singletons in the main container (as they are today), but put all the tenancy-sensitive components in new child container that has
DefaultReuse = ReuseScope.Request, rather then just adding
.ReuseWithin(ReuseScope.Request) on every one of them (there are about 100 of them).
If I was to do that though, I am not sure how GlobalFilters, RequestFilters and other extensions that make calls like
IRequest.TryResolve<T> are going to resolve if the components are in a child container, rather that in the main container, so might be adding more complexity than necessary.
Is using a child container like this a feasible pattern, or should I revert back to just adding
.ReuseWithin(ReuseScope.Request) to my components? Or is there another option?