Skip to content

Commit

Permalink
DP-1013: Add a falback if ElastiCache fails to start
Browse files Browse the repository at this point in the history
  • Loading branch information
mareg committed Jan 13, 2025
1 parent d980285 commit a1720b2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Libraries/CO.CDP.AwsServices/ElastiCacheExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ public static IServiceCollection AddSharedSessions(this IServiceCollection servi
{
if (configuration.GetValue<bool>("Features:SharedSessions"))
{
Console.WriteLine("SharedSession is enabled.");
services.AddElastiCacheService();
}
else
{
Console.WriteLine("SharedSession is disabled.");
services.AddDistributedMemoryCache();
try
{
services.AddElastiCacheService();
Console.WriteLine("SharedSession is enabled.");

return services;
}
catch (Exception ex)
{
Console.WriteLine("SharedSession failed to start with: " + ex.Message);
}
}

services.AddDistributedMemoryCache();
Console.WriteLine("SharedSession is disabled.");

return services;
}

Expand Down

0 comments on commit a1720b2

Please sign in to comment.