Support existing document store and index creation behind toggle#10
Support existing document store and index creation behind toggle#10lahma wants to merge 1 commit intoravendb:masterfrom
Conversation
| services.AddSingleton(provider => new ConfigurationDocumentStoreHolder(options)); | ||
|
|
||
| services.AddSingleton(provider => options.ResolveDocumentStoreFromServices | ||
| ? new ConfigurationDocumentStoreHolder(provider.GetRequiredService<IDocumentStore>(), options) |
There was a problem hiding this comment.
There are a few issues with this approach.
Firstly, it introduces redundant complexity, which in turn requires additional validation. What if ResolveDocumentStoreFromServices is true and the IDocumentStore has not been added to the services container?
Secondly, a user might want to provide the library with their own IDocumentStore which is not necessarily resolved by the DI mechanism directly. For example, it might be a property existing on some other object. This is the pattern that we often apply in our internal projects at HibernatingRhinos. In that case we would need another option pointing to where the library should look for the IDocumentStore object.
How about we add at least two more IIdentityServerBuilder extension methods? One of them accepting IDocumentStore object and another one taking a Func<IDocumentStore> provider as a parameter. That way we would let users inject their DocumentStores wherever they want from.
|
@lahma Thank you for drawing out attention to the |
This PR adds support to reuse an existing document store from service proivder (we configure it globally and share it with other services too) instead of creating a new document store.
Also adding a toggle whether indexes should be deployed automatically - we have custom migrations (RavenMigrations) and the process also includes refreshing the indexes. We don't want indexes to refresh outside of deployment process.