public void ConfigureServices(IServiceCollection services) { var configuration = new PassthroughConfiguration( connectionFunc: () => new SqlConnection(Connection.ConnectionString), callback: AmendMessage, dedupCriticalError: exception => { Environment.FailFast("", exception); }); configuration.AppendClaimsToMessageHeaders(); services.AddSqlHttpPassthrough(configuration); services.AddMvcCore(options => options.EnableEndpointRouting = false); }
public void ConfigureServices(IServiceCollection services) { var configuration = new PassthroughConfiguration( connectionFunc: OpenConnection, callback: AmendMessage, dedupCriticalError: exception => { Environment.FailFast("Dedup failure", exception); }); services.AddSqlHttpPassthrough(configuration); services.AddMvcCore(); }
public void Default(IServiceCollection services) { #region AppendClaimsToMessageHeaders var configuration = new PassthroughConfiguration( connectionFunc: OpenConnection, callback: Callback, dedupCriticalError: exception => { Environment.FailFast("Dedup cleanup failure", exception); }); configuration.AppendClaimsToMessageHeaders(); services.AddSqlHttpPassthrough(configuration); #endregion }
/// <summary> /// Add Sql HTTP Passthrough to an instance of <see cref="IServiceCollection"/>. /// Used from <code>Startup.ConfigureServices</code>. /// </summary> public static void AddSqlHttpPassthrough( this IServiceCollection services, PassthroughConfiguration configuration) { var headersBuilder = new HeadersBuilder(configuration.OriginatingEndpoint, configuration.OriginatingMachine); services.AddSingleton <ISqlPassthrough>(serviceProvider => { var loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>(); var logger = loggerFactory.CreateLogger <ISqlPassthrough>(); var sender = new Sender(configuration.ConnectionFunc, headersBuilder, configuration.AttachmentsTable, configuration.DedupeTable, logger); return(new SqlPassthrough(configuration.SendCallback, sender, configuration.AppendClaims, configuration.ClaimsHeaderPrefix, logger)); }); var dedupService = new DedupService(configuration.DedupeTable, configuration.ConnectionFunc, configuration.DedupCriticalError); services.AddSingleton <IHostedService>(dedupService); }