Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow persistence to be explicitly selected #1034

Open
rlf opened this issue May 31, 2024 · 1 comment
Open

Allow persistence to be explicitly selected #1034

rlf opened this issue May 31, 2024 · 1 comment

Comments

@rlf
Copy link

rlf commented May 31, 2024

With the current extension methods, it would seem that the following would be selecting PostgreSql as persisitence:

services.AddEventFlow(o => o.UsePostgreSqlEventStore());

Unfortunately that is not the case, since the TryAdd in this line:
https://github.com/eventflow/EventFlow/blob/develop-v1/Source/EventFlow.PostgreSql/Extensions/EventFlowOptionsPostgresSqlEventStoreExtensions.cs#L34

Won't replace the TryAdd in this line:

serviceCollection.TryAddSingleton<IEventPersistence, InMemoryEventPersistence>();

A current workaround would be to either do:

services.TryAddTransient<IEventPersistence, PostgreSqlEventPersistence>();
services.AddEventFlow(o => {});

or

services.AddEventFlow(o => {});
services.AddTransient<IEventPersistence, PostgreSqlEventPersistence>();

But to me it seems that if you specifically use the UsePostgreSqlEventStore extension, it should be safe to add without try (i.e. overrule the sane defaults).

@rasmus
Copy link
Member

rasmus commented Jun 3, 2024

Seems like a good change and possible a mistake on my part when I moved everything to the new extensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants