feat: migrate snowflake ids and refresh migrations
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TakeoutSaaS.Shared.Abstractions.Diagnostics;
|
||||
using TakeoutSaaS.Shared.Abstractions.Ids;
|
||||
|
||||
namespace TakeoutSaaS.Shared.Web.Middleware;
|
||||
|
||||
@@ -17,11 +18,13 @@ public sealed class CorrelationIdMiddleware
|
||||
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly ILogger<CorrelationIdMiddleware> _logger;
|
||||
private readonly IIdGenerator _idGenerator;
|
||||
|
||||
public CorrelationIdMiddleware(RequestDelegate next, ILogger<CorrelationIdMiddleware> logger)
|
||||
public CorrelationIdMiddleware(RequestDelegate next, ILogger<CorrelationIdMiddleware> logger, IIdGenerator idGenerator)
|
||||
{
|
||||
_next = next;
|
||||
_logger = logger;
|
||||
_idGenerator = idGenerator;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
@@ -52,7 +55,7 @@ public sealed class CorrelationIdMiddleware
|
||||
}
|
||||
}
|
||||
|
||||
private static string ResolveTraceId(HttpContext context)
|
||||
private string ResolveTraceId(HttpContext context)
|
||||
{
|
||||
if (TryGetHeader(context, TraceHeader, out var traceId))
|
||||
{
|
||||
@@ -64,7 +67,7 @@ public sealed class CorrelationIdMiddleware
|
||||
return requestId;
|
||||
}
|
||||
|
||||
return Guid.NewGuid().ToString("N");
|
||||
return _idGenerator.NextId().ToString();
|
||||
}
|
||||
|
||||
private static bool TryGetHeader(HttpContext context, string headerName, out string value)
|
||||
|
||||
Reference in New Issue
Block a user