Add unit tests for Router configuration and transport layers
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled

- Implemented tests for RouterConfig, RoutingOptions, StaticInstanceConfig, and RouterConfigOptions to ensure default values are set correctly.
- Added tests for RouterConfigProvider to validate configurations and ensure defaults are returned when no file is specified.
- Created tests for ConfigValidationResult to check success and error scenarios.
- Developed tests for ServiceCollectionExtensions to verify service registration for RouterConfig.
- Introduced UdpTransportTests to validate serialization, connection, request-response, and error handling in UDP transport.
- Added scripts for signing authority gaps and hashing DevPortal SDK snippets.
This commit is contained in:
StellaOps Bot
2025-12-05 08:01:47 +02:00
parent 635c70e828
commit 6a299d231f
294 changed files with 28434 additions and 1329 deletions

View File

@@ -7,6 +7,38 @@ namespace StellaOps.Router.Common.Abstractions;
/// </summary>
public interface IGlobalRoutingState
{
/// <summary>
/// Adds a connection to the routing state.
/// </summary>
/// <param name="connection">The connection state to add.</param>
void AddConnection(ConnectionState connection);
/// <summary>
/// Removes a connection from the routing state.
/// </summary>
/// <param name="connectionId">The connection ID to remove.</param>
void RemoveConnection(string connectionId);
/// <summary>
/// Updates an existing connection's state.
/// </summary>
/// <param name="connectionId">The connection ID to update.</param>
/// <param name="update">The update action to apply.</param>
void UpdateConnection(string connectionId, Action<ConnectionState> update);
/// <summary>
/// Gets a connection by its ID.
/// </summary>
/// <param name="connectionId">The connection ID.</param>
/// <returns>The connection state, or null if not found.</returns>
ConnectionState? GetConnection(string connectionId);
/// <summary>
/// Gets all active connections.
/// </summary>
/// <returns>All active connections.</returns>
IReadOnlyList<ConnectionState> GetAllConnections();
/// <summary>
/// Resolves an HTTP request to an endpoint descriptor.
/// </summary>

View File

@@ -0,0 +1,43 @@
using StellaOps.Router.Common.Models;
namespace StellaOps.Router.Common.Abstractions;
/// <summary>
/// Represents a transport connection from a microservice to the gateway.
/// This interface is used by the Microservice SDK to communicate with the router.
/// </summary>
public interface IMicroserviceTransport
{
/// <summary>
/// Connects to the router and registers the microservice.
/// </summary>
/// <param name="instance">The instance descriptor.</param>
/// <param name="endpoints">The endpoints to register.</param>
/// <param name="cancellationToken">Cancellation token.</param>
Task ConnectAsync(
InstanceDescriptor instance,
IReadOnlyList<EndpointDescriptor> endpoints,
CancellationToken cancellationToken);
/// <summary>
/// Disconnects from the router.
/// </summary>
Task DisconnectAsync();
/// <summary>
/// Sends a heartbeat to the router.
/// </summary>
/// <param name="heartbeat">The heartbeat payload.</param>
/// <param name="cancellationToken">Cancellation token.</param>
Task SendHeartbeatAsync(HeartbeatPayload heartbeat, CancellationToken cancellationToken);
/// <summary>
/// Event raised when a REQUEST frame is received from the gateway.
/// </summary>
event Func<Frame, CancellationToken, Task<Frame>>? OnRequestReceived;
/// <summary>
/// Event raised when a CANCEL frame is received from the gateway.
/// </summary>
event Func<Guid, string?, Task>? OnCancelReceived;
}