Files
git.stella-ops.org/src/Scanner/__Libraries/StellaOps.Scanner.Reachability/ReachabilityUnionPublisherService.cs
2026-02-01 21:37:40 +02:00

42 lines
1.6 KiB
C#

using StellaOps.Scanner.Cache.Abstractions;
using StellaOps.Scanner.Surface.Env;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace StellaOps.Scanner.Reachability;
public interface IReachabilityUnionPublisherService
{
Task<ReachabilityUnionPublishResult> PublishAsync(ReachabilityUnionGraph graph, string analysisId, CancellationToken cancellationToken = default);
}
/// <summary>
/// Default service that writes a union graph to CAS using the worker surface cache root.
/// </summary>
public sealed class ReachabilityUnionPublisherService : IReachabilityUnionPublisherService
{
private readonly ISurfaceEnvironment environment;
private readonly IFileContentAddressableStore cas;
private readonly ReachabilityUnionPublisher publisher;
public ReachabilityUnionPublisherService(
ISurfaceEnvironment environment,
IFileContentAddressableStore cas,
ReachabilityUnionPublisher publisher)
{
this.environment = environment ?? throw new ArgumentNullException(nameof(environment));
this.cas = cas ?? throw new ArgumentNullException(nameof(cas));
this.publisher = publisher ?? throw new ArgumentNullException(nameof(publisher));
}
public Task<ReachabilityUnionPublishResult> PublishAsync(ReachabilityUnionGraph graph, string analysisId, CancellationToken cancellationToken = default)
{
var workRoot = Path.Combine(environment.Settings.CacheRoot.FullName, "reachability");
Directory.CreateDirectory(workRoot);
return publisher.PublishAsync(graph, cas, workRoot, analysisId, cancellationToken);
}
}