EventFlow icon indicating copy to clipboard operation
EventFlow copied to clipboard

Allow persistence to be explicitly selected

Open rlf opened this issue 1 year ago • 1 comments

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: https://github.com/eventflow/EventFlow/blob/bb46378162511b53989f6f94357126bc76673dc1/Source/EventFlow/EventFlowOptions.cs#L185

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).

rlf avatar May 31 '24 12:05 rlf

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

rasmus avatar Jun 03 '24 06:06 rasmus