Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private IConfigurationRoot SetupMemoryConfiguration()

configuration.Add("ConnectionStrings:HealthCheck", "HeathCheckConnString");
configuration.Add("SecurityConfiguration:Authority", "https://127.0.0.1");
configuration.Add("EventStoreSettings:ConnectionString", "https://127.0.0.1:2113");
configuration.Add("EventStoreSettings:ConnectionString", "esdb://127.0.0.1:2113");
configuration.Add("EventStoreSettings:ConnectionName", "UnitTestConnection");
configuration.Add("EventStoreSettings:UserName", "admin");
configuration.Add("EventStoreSettings:Password", "changeit");
Expand Down
2 changes: 1 addition & 1 deletion CallbackHandler.Tests/BootstrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private IConfigurationRoot SetupMemoryConfiguration()

configuration.Add("ConnectionStrings:HealthCheck", "HeathCheckConnString");
configuration.Add("SecurityConfiguration:Authority", "https://127.0.0.1");
configuration.Add("EventStoreSettings:ConnectionString", "https://127.0.0.1:2113");
configuration.Add("EventStoreSettings:ConnectionString", "esdb://127.0.0.1:2113");
configuration.Add("EventStoreSettings:ConnectionName", "UnitTestConnection");
configuration.Add("EventStoreSettings:UserName", "admin");
configuration.Add("EventStoreSettings:Password", "changeit");
Expand Down
19 changes: 12 additions & 7 deletions CallbackHandler/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System.IO;
using System.Reflection;
using Common;
using EventStore.Client;
using Lamar;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.OpenApi.Models;
Expand All @@ -19,11 +21,14 @@ public class MiddlewareRegistry :ServiceRegistry
{
public MiddlewareRegistry()
{
this.AddHealthChecks().AddEventStore(Startup.EventStoreClientSettings,
userCredentials: Startup.EventStoreClientSettings.DefaultCredentials,
name: "Eventstore",
failureStatus: HealthStatus.Unhealthy,
tags: new string[] { "db", "eventstore" });
String connectionString = Startup.Configuration.GetValue<String>("EventStoreSettings:ConnectionString");
EventStoreClientSettings eventStoreSettings = EventStoreClientSettings.Create(connectionString);

this.AddHealthChecks().AddEventStore(eventStoreSettings,
userCredentials: eventStoreSettings.DefaultCredentials,
name: "Eventstore",
failureStatus: HealthStatus.Unhealthy,
tags: new string[] { "db", "eventstore" });

this.AddSwaggerGen(c =>
{
Expand All @@ -43,8 +48,8 @@ public MiddlewareRegistry()
c.ExampleFilters();

//Locate the XML files being generated by ASP.NET...
var directory = new DirectoryInfo(AppContext.BaseDirectory);
var xmlFiles = directory.GetFiles("*.xml");
DirectoryInfo directory = new DirectoryInfo(AppContext.BaseDirectory);
FileInfo[] xmlFiles = directory.GetFiles("*.xml");

//... and tell Swagger to use those XML comments.
foreach (FileInfo fileInfo in xmlFiles)
Expand Down
27 changes: 4 additions & 23 deletions CallbackHandler/Bootstrapper/RepositoryRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,12 @@ public RepositoryRegistry()
{
this.AddTransient<IEventStoreContext, EventStoreContext>();
this.AddSingleton<IAggregateRepository<CallbackMessageAggregate, DomainEvent>, AggregateRepository<CallbackMessageAggregate, DomainEvent>>();

Boolean insecureES = Startup.Configuration.GetValue<Boolean>("EventStoreSettings:Insecure");

Func<SocketsHttpHandler> CreateHttpMessageHandler = () => new SocketsHttpHandler
{
SslOptions = new SslClientAuthenticationOptions
{
RemoteCertificateValidationCallback = (sender,
certificate,
chain,
errors) => {
return true;
}
}
};
String connectionString = Startup.Configuration.GetValue<String>("EventStoreSettings:ConnectionString");

this.AddEventStoreProjectionManagementClient(Startup.ConfigureEventStoreSettings);
this.AddEventStoreProjectionManagementClient(connectionString);
this.AddEventStorePersistentSubscriptionsClient(connectionString);

if (insecureES)
{
this.AddInSecureEventStoreClient(Startup.EventStoreClientSettings.ConnectivitySettings.Address, CreateHttpMessageHandler);
}
else
{
this.AddEventStoreClient(Startup.EventStoreClientSettings.ConnectivitySettings.Address, CreateHttpMessageHandler);
}
this.AddEventStoreClient(connectionString);
}
}
13 changes: 0 additions & 13 deletions CallbackHandler/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,6 @@ public Startup(IWebHostEnvironment webHostEnvironment)
/// </value>
public static IWebHostEnvironment WebHostEnvironment { get; set; }

internal static EventStoreClientSettings EventStoreClientSettings;

internal static void ConfigureEventStoreSettings(EventStoreClientSettings settings)
{
settings.ConnectivitySettings = EventStoreClientConnectivitySettings.Default;
settings.ConnectivitySettings.Address = new Uri(Startup.Configuration.GetValue<String>("EventStoreSettings:ConnectionString"));
settings.ConnectivitySettings.Insecure = Startup.Configuration.GetValue<Boolean>("EventStoreSettings:Insecure");

settings.DefaultCredentials = new UserCredentials(Startup.Configuration.GetValue<String>("EventStoreSettings:UserName"),
Startup.Configuration.GetValue<String>("EventStoreSettings:Password"));
Startup.EventStoreClientSettings = settings;
}

public static Container Container;
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureContainer(ServiceRegistry services)
Expand Down