static ExactlyOnceConfiguration RegisterServices(this IServiceCollection services) { var outboxConfiguration = new OutboxConfiguration(); var configuration = new ExactlyOnceConfiguration(outboxConfiguration); services.AddLogging(); services.AddSingleton <IOnceExecutor>(sp => { var stateStore = (IStateStore)sp.GetRequiredService(configuration.StateStoreType); var client = sp.GetRequiredService <CosmosClient>(); var outboxStore = new OutboxStore(client, outboxConfiguration); var processor = new ExactlyOnceProcessor(outboxStore, stateStore); var onceExecutor = new OnceExecutor(processor); return(onceExecutor); }); return(configuration); }
static ExactlyOnceConfiguration RegisterServices(this IServiceCollection services) { var outboxConfiguration = new OutboxConfiguration(); var configuration = new ExactlyOnceConfiguration(outboxConfiguration); services.AddLogging(); services.AddSingleton(sp => { var client = configuration.CosmosClientFactory(); var stateStore = new CosmosDbStateStore(client, outboxConfiguration.DatabaseId); var outboxStore = new OutboxStore(client, outboxConfiguration); return(new ExactlyOnceProcessor(outboxStore, stateStore)); }); services.AddSingleton <OnceExecutorFactory>(); return(configuration); }