release orchestrator v1 draft and build fixes
This commit is contained in:
@@ -12,6 +12,12 @@ public sealed class InMemoryOrchestratorRegistryStore : IOrchestratorRegistrySto
|
||||
private readonly ConcurrentDictionary<(string Tenant, string ConnectorId, Guid RunId), List<OrchestratorHeartbeatRecord>> _heartbeats = new();
|
||||
private readonly ConcurrentDictionary<(string Tenant, string ConnectorId, Guid RunId), List<OrchestratorCommandRecord>> _commands = new();
|
||||
private readonly ConcurrentDictionary<(string Tenant, string ConnectorId, Guid RunId), OrchestratorRunManifest> _manifests = new();
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public InMemoryOrchestratorRegistryStore(TimeProvider? timeProvider = null)
|
||||
{
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task UpsertAsync(OrchestratorRegistryRecord record, CancellationToken cancellationToken)
|
||||
@@ -99,7 +105,7 @@ public sealed class InMemoryOrchestratorRegistryStore : IOrchestratorRegistrySto
|
||||
|
||||
lock (commands)
|
||||
{
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var now = _timeProvider.GetUtcNow();
|
||||
var pending = commands
|
||||
.Where(c => (afterSequence is null || c.Sequence > afterSequence)
|
||||
&& (c.ExpiresAt is null || c.ExpiresAt > now))
|
||||
|
||||
@@ -19,8 +19,11 @@ public sealed record TenantScope(
|
||||
/// <summary>
|
||||
/// Validates that the tenant scope is well-formed.
|
||||
/// </summary>
|
||||
public void Validate()
|
||||
/// <param name="asOf">The time to check expiry against. Defaults to current UTC time.</param>
|
||||
public void Validate(DateTimeOffset? asOf = null)
|
||||
{
|
||||
var now = asOf ?? DateTimeOffset.UtcNow;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TenantId))
|
||||
{
|
||||
throw new TenantScopeException("auth/tenant-scope-missing", "TenantId is required");
|
||||
@@ -41,7 +44,7 @@ public sealed record TenantScope(
|
||||
throw new TenantScopeException("auth/tenant-scope-missing", "Required concelier scope missing");
|
||||
}
|
||||
|
||||
if (ExpiresAt <= DateTimeOffset.UtcNow)
|
||||
if (ExpiresAt <= now)
|
||||
{
|
||||
throw new TenantScopeException("auth/token-expired", "Token has expired");
|
||||
}
|
||||
|
||||
@@ -21,17 +21,20 @@ public sealed class BundleExportService : IBundleExportService
|
||||
private readonly IBundleSigner _signer;
|
||||
private readonly FederationOptions _options;
|
||||
private readonly ILogger<BundleExportService> _logger;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public BundleExportService(
|
||||
IDeltaQueryService deltaQuery,
|
||||
IBundleSigner signer,
|
||||
IOptions<FederationOptions> options,
|
||||
ILogger<BundleExportService> logger)
|
||||
ILogger<BundleExportService> logger,
|
||||
TimeProvider? timeProvider = null)
|
||||
{
|
||||
_deltaQuery = deltaQuery;
|
||||
_signer = signer;
|
||||
_options = options.Value;
|
||||
_logger = logger;
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -164,7 +167,7 @@ public sealed class BundleExportService : IBundleExportService
|
||||
await WriteEntryAsync(tarWriter, "deletions.ndjson", deletionBuffer, ct);
|
||||
|
||||
// Generate new cursor
|
||||
var exportCursor = CursorFormat.Create(DateTimeOffset.UtcNow);
|
||||
var exportCursor = CursorFormat.Create(_timeProvider.GetUtcNow());
|
||||
|
||||
// Build manifest
|
||||
var manifest = new BundleManifest
|
||||
@@ -173,7 +176,7 @@ public sealed class BundleExportService : IBundleExportService
|
||||
SiteId = _options.SiteId,
|
||||
ExportCursor = exportCursor,
|
||||
SinceCursor = sinceCursor,
|
||||
ExportedAt = DateTimeOffset.UtcNow,
|
||||
ExportedAt = _timeProvider.GetUtcNow(),
|
||||
Counts = new BundleCounts
|
||||
{
|
||||
Canonicals = canonicalCount,
|
||||
|
||||
@@ -14,13 +14,16 @@ public sealed class DeltaQueryService : IDeltaQueryService
|
||||
{
|
||||
private readonly ICanonicalAdvisoryStore _canonicalStore;
|
||||
private readonly ILogger<DeltaQueryService> _logger;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public DeltaQueryService(
|
||||
ICanonicalAdvisoryStore canonicalStore,
|
||||
ILogger<DeltaQueryService> logger)
|
||||
ILogger<DeltaQueryService> logger,
|
||||
TimeProvider? timeProvider = null)
|
||||
{
|
||||
_canonicalStore = canonicalStore;
|
||||
_logger = logger;
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -32,7 +35,7 @@ public sealed class DeltaQueryService : IDeltaQueryService
|
||||
options ??= new DeltaQueryOptions();
|
||||
|
||||
var sinceTimestamp = ParseCursor(sinceCursor);
|
||||
var newCursor = CursorFormat.Create(DateTimeOffset.UtcNow);
|
||||
var newCursor = CursorFormat.Create(_timeProvider.GetUtcNow());
|
||||
|
||||
_logger.LogInformation(
|
||||
"Querying changes since {Cursor} (timestamp: {Since})",
|
||||
|
||||
Reference in New Issue
Block a user