release orchestrator v1 draft and build fixes
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Npgsql;
|
||||
using StellaOps.Determinism;
|
||||
using StellaOps.Graph.Indexer.Ingestion.Sbom;
|
||||
using StellaOps.Infrastructure.Postgres.Repositories;
|
||||
|
||||
@@ -18,11 +19,18 @@ public sealed class PostgresGraphDocumentWriter : RepositoryBase<GraphIndexerDat
|
||||
WriteIndented = false
|
||||
};
|
||||
|
||||
private bool _tableInitialized;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
private readonly IGuidProvider _guidProvider; private bool _tableInitialized;
|
||||
|
||||
public PostgresGraphDocumentWriter(GraphIndexerDataSource dataSource, ILogger<PostgresGraphDocumentWriter> logger)
|
||||
public PostgresGraphDocumentWriter(
|
||||
GraphIndexerDataSource dataSource,
|
||||
ILogger<PostgresGraphDocumentWriter> logger,
|
||||
TimeProvider? timeProvider = null,
|
||||
IGuidProvider? guidProvider = null)
|
||||
: base(dataSource, logger)
|
||||
{
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
_guidProvider = guidProvider ?? SystemGuidProvider.Instance;
|
||||
}
|
||||
|
||||
public async Task WriteAsync(GraphBuildBatch batch, CancellationToken cancellationToken)
|
||||
@@ -36,8 +44,8 @@ public sealed class PostgresGraphDocumentWriter : RepositoryBase<GraphIndexerDat
|
||||
|
||||
try
|
||||
{
|
||||
var batchId = Guid.NewGuid().ToString("N");
|
||||
var writtenAt = DateTimeOffset.UtcNow;
|
||||
var batchId = _guidProvider.NewGuid().ToString("N");
|
||||
var writtenAt = _timeProvider.GetUtcNow();
|
||||
|
||||
// Insert nodes
|
||||
foreach (var node in batch.Nodes)
|
||||
@@ -98,9 +106,9 @@ public sealed class PostgresGraphDocumentWriter : RepositoryBase<GraphIndexerDat
|
||||
}
|
||||
}
|
||||
|
||||
private static string ExtractId(JsonObject node)
|
||||
private string ExtractId(JsonObject node)
|
||||
{
|
||||
return ExtractString(node, "id") ?? ExtractString(node, "@id") ?? Guid.NewGuid().ToString("N");
|
||||
return ExtractString(node, "id") ?? ExtractString(node, "@id") ?? _guidProvider.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
private static string ExtractEdgeId(JsonObject edge)
|
||||
|
||||
@@ -20,10 +20,15 @@ public sealed class PostgresGraphSnapshotProvider : RepositoryBase<GraphIndexerD
|
||||
};
|
||||
|
||||
private bool _tableInitialized;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public PostgresGraphSnapshotProvider(GraphIndexerDataSource dataSource, ILogger<PostgresGraphSnapshotProvider> logger)
|
||||
public PostgresGraphSnapshotProvider(
|
||||
GraphIndexerDataSource dataSource,
|
||||
ILogger<PostgresGraphSnapshotProvider> logger,
|
||||
TimeProvider? timeProvider = null)
|
||||
: base(dataSource, logger)
|
||||
{
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,7 +59,7 @@ public sealed class PostgresGraphSnapshotProvider : RepositoryBase<GraphIndexerD
|
||||
AddParameter(command, "@generated_at", snapshot.GeneratedAt);
|
||||
AddJsonbParameter(command, "@nodes_json", nodesJson);
|
||||
AddJsonbParameter(command, "@edges_json", edgesJson);
|
||||
AddParameter(command, "@queued_at", DateTimeOffset.UtcNow);
|
||||
AddParameter(command, "@queued_at", _timeProvider.GetUtcNow());
|
||||
|
||||
await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -23,5 +23,6 @@
|
||||
<ProjectReference Include="..\..\StellaOps.Graph.Indexer\StellaOps.Graph.Indexer.csproj" />
|
||||
<ProjectReference Include="..\..\..\__Libraries\StellaOps.Infrastructure.Postgres\StellaOps.Infrastructure.Postgres.csproj" />
|
||||
<ProjectReference Include="..\..\..\__Libraries\StellaOps.Infrastructure.EfCore\StellaOps.Infrastructure.EfCore.csproj" />
|
||||
<ProjectReference Include="..\..\..\__Libraries\StellaOps.Determinism.Abstractions\StellaOps.Determinism.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user