nuget reorganization

This commit is contained in:
master
2025-11-18 23:45:25 +02:00
parent 77cee6a209
commit d3ecd7f8e6
7712 changed files with 13963 additions and 10007504 deletions

View File

@@ -0,0 +1,60 @@
using System;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using StellaOps.Signals.Models;
using StellaOps.Signals.Options;
namespace StellaOps.Signals.Services;
/// <summary>
/// Placeholder events publisher; replace with real bus integration when contracts are finalized.
/// </summary>
internal sealed class InMemoryEventsPublisher : IEventsPublisher
{
private readonly ILogger<InMemoryEventsPublisher> logger;
private readonly string topic;
public InMemoryEventsPublisher(ILogger<InMemoryEventsPublisher> logger, SignalsOptions options)
{
this.logger = logger;
topic = string.IsNullOrWhiteSpace(options?.AirGap?.EventTopic)
? "signals.fact.updated"
: options!.AirGap.EventTopic!;
}
public Task PublishFactUpdatedAsync(ReachabilityFactDocument fact, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(fact);
var (reachable, unreachable) = CountStates(fact);
var runtimeFactsCount = fact.RuntimeFacts?.Count ?? 0;
var payload = new ReachabilityFactUpdatedEvent(
Version: "signals.fact.updated@v1",
SubjectKey: fact.SubjectKey,
CallgraphId: string.IsNullOrWhiteSpace(fact.CallgraphId) ? null : fact.CallgraphId,
OccurredAtUtc: DateTimeOffset.UtcNow,
ReachableCount: reachable,
UnreachableCount: unreachable,
RuntimeFactsCount: runtimeFactsCount,
ComputedAtUtc: fact.ComputedAt);
var json = JsonSerializer.Serialize(payload, new JsonSerializerOptions(JsonSerializerDefaults.Web));
logger.LogInformation("{Topic} {Payload}", topic, json);
return Task.CompletedTask;
}
private static (int reachable, int unreachable) CountStates(ReachabilityFactDocument fact)
{
if (fact.States is null || fact.States.Count == 0)
{
return (0, 0);
}
var reachable = fact.States.Count(state => state.Reachable);
var unreachable = fact.States.Count - reachable;
return (reachable, unreachable);
}
}