Skip to content

Commit

Permalink
Use S3 storage when running local
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Dec 18, 2024
1 parent b41f15f commit b4e714d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/Exceptionless.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.WithDataVolume("exceptionless.data.v1")
.WithKibana(b => b.WithLifetime(ContainerLifetime.Persistent).WithContainerName("Exceptionless-Kibana"));

var storage = builder.AddMinIo("Storage", s => s.WithCredentials("guest", "password").WithPorts(9000))
var storage = builder.AddMinIo("S3", s => s.WithCredentials("guest", "password").WithPorts(9000))
.WithLifetime(ContainerLifetime.Persistent)
.WithContainerName("Exceptionless-Storage");

Expand All @@ -26,6 +26,7 @@
builder.AddProject<Projects.Exceptionless_Job>("Jobs", "AllJobs")
.WithReference(cache)
.WithReference(elastic)
.WithReference(storage)
.WithEnvironment("ConnectionStrings:Email", "smtp://localhost:1025")
.WaitFor(elastic)
.WaitFor(cache)
Expand Down
25 changes: 19 additions & 6 deletions src/Exceptionless.Core/Configuration/StorageOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,31 @@ public class StorageOptions

public static StorageOptions ReadFromConfiguration(IConfiguration config, AppOptions appOptions)
{
var options = new StorageOptions();

options.Scope = appOptions.AppScope;
var options = new StorageOptions { Scope = appOptions.AppScope };
options.ScopePrefix = !String.IsNullOrEmpty(options.Scope) ? $"{options.Scope}-" : String.Empty;

string? cs = config.GetConnectionString("Storage");
options.Data = cs.ParseConnectionString();
options.Provider = options.Data.GetString(nameof(options.Provider));
if (cs != null)
{
options.Data = cs.ParseConnectionString();
options.Provider = options.Data.GetString(nameof(options.Provider));
}
else
{
var minioConnectionString = config.GetConnectionString("S3");
if (!String.IsNullOrEmpty(minioConnectionString))
{
options.Provider = "s3";
}
}

string? providerConnectionString = !String.IsNullOrEmpty(options.Provider) ? config.GetConnectionString(options.Provider) : null;
if (!String.IsNullOrEmpty(providerConnectionString))
options.Data.AddRange(providerConnectionString.ParseConnectionString());
{
var providerOptions = providerConnectionString.ParseConnectionString(defaultKey: "server");
options.Data ??= [];
options.Data.AddRange(providerOptions);
}

options.ConnectionString = options.Data.BuildConnectionString(new HashSet<string> { nameof(options.Provider) });

Expand Down
10 changes: 5 additions & 5 deletions src/Exceptionless.Insulation/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,22 @@ private static void RegisterQueue(IServiceCollection container, QueueOptions opt

private static void RegisterStorage(IServiceCollection container, StorageOptions options)
{
if (String.Equals(options.Provider, "aliyun"))
if (String.Equals(options.Provider, "azurestorage"))
{
container.ReplaceSingleton<IFileStorage>(s => new AliyunFileStorage(new AliyunFileStorageOptions
container.ReplaceSingleton<IFileStorage>(s => new AzureFileStorage(new AzureFileStorageOptions
{
ConnectionString = options.ConnectionString,
ContainerName = $"{options.ScopePrefix}ex-events",
Serializer = s.GetRequiredService<ITextSerializer>(),
TimeProvider = s.GetRequiredService<TimeProvider>(),
LoggerFactory = s.GetRequiredService<ILoggerFactory>()
}));
}
else if (String.Equals(options.Provider, "azurestorage"))
else if (String.Equals(options.Provider, "aliyun"))
{
container.ReplaceSingleton<IFileStorage>(s => new AzureFileStorage(new AzureFileStorageOptions
container.ReplaceSingleton<IFileStorage>(s => new AliyunFileStorage(new AliyunFileStorageOptions
{
ConnectionString = options.ConnectionString,
ContainerName = $"{options.ScopePrefix}ex-events",
Serializer = s.GetRequiredService<ITextSerializer>(),
TimeProvider = s.GetRequiredService<TimeProvider>(),
LoggerFactory = s.GetRequiredService<ILoggerFactory>()
Expand Down
34 changes: 17 additions & 17 deletions src/Exceptionless.Job/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"CleanupDataJob": {
Expand All @@ -14,7 +14,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"DataMigrationJob": {
Expand All @@ -23,7 +23,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"MigrationJob": {
Expand All @@ -32,7 +32,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"EventPostsJob": {
Expand All @@ -41,7 +41,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"EventUserDescriptionsJob": {
Expand All @@ -50,7 +50,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"EventNotificationsJob": {
Expand All @@ -59,7 +59,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"MailMessageJob": {
Expand All @@ -68,7 +68,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"WebHooksJob": {
Expand All @@ -77,7 +77,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"CloseInactiveSessionsJob": {
Expand All @@ -86,7 +86,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"DailySummaryJob": {
Expand All @@ -95,7 +95,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"DownloadGeoIPDatabaseJob": {
Expand All @@ -104,7 +104,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"WorkItemJob": {
Expand All @@ -113,7 +113,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"MaintainIndexesJob": {
Expand All @@ -122,7 +122,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"StackEventCountJob": {
Expand All @@ -131,7 +131,7 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
},
"EventSnapshotJob": {
Expand All @@ -140,8 +140,8 @@
"environmentVariables": {
"EX_AppMode": "Development"
},
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002;http://localhost:5003"
}
}
}
}
2 changes: 1 addition & 1 deletion src/Exceptionless.Job/appsettings.Development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ConnectionStrings:
# Cache: provider=redis;
# MessageBus: provider=redis;
# Queue: provider=redis;
Storage: provider=folder;path=..\Exceptionless.Web\storage
# Storage: provider=folder;path=..\Exceptionless.Web\storage
Email: smtp://localhost:1025

# Base url for the ui used to build links in emails and other places.
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptionless.Web/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Exceptionless": {
"commandName": "Project",
"launchBrowser": true,
"launchBrowser": false,
"environmentVariables": {
"EX_AppMode": "Development"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptionless.Web/appsettings.Development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ConnectionStrings:
# Cache: provider=redis;
# MessageBus: provider=redis;
# Queue: provider=redis;
Storage: provider=folder;path=.\storage
# Storage: provider=folder;path=.\storage
# LDAP: ''
# Email: smtp://localhost:1025

Expand Down

0 comments on commit b4e714d

Please sign in to comment.