dotnetcore / CAP

Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
http://cap.dotnetcore.xyz
MIT License
6.68k stars 1.28k forks source link

fix(#435): use TryAddSingleton when registering IStorageInitializer to avoid overwriting user configured initialisers #1490

Open esskar opened 8 months ago

esskar commented 8 months ago

Description:

It was not obvious how this feature works. adding a custom IStorageInitializer before calling UseCap is not working as the registration will get overwritten. This is not the case for the MySQL Initializer as this was already using the TryAddSingleton functionality

Issue(s) addressed:

Changes:

Affected components:

Additional notes (optional):

I noticed that setting a custom IStorageInitializer

Checklist:

demorgi commented 1 week ago

as a temporary workaround you can override registration After options.UseMongoDB do services.RemoveAll<IStorageInitializer>(); services.AddSingleton<IStorageInitializer, CustomStorageInitializer>();