Add networking foundation — 9-project C# solution (compiles clean)

Implements the modular networking layer for SOR Server:
- SOR.Networking.Abstractions: pure interfaces (ITransport, IClientConnection,
  IMessageSerializer, IMessageDispatcher, IMessageHandler, IEventBus, IClientPush)
- SOR.Networking.WebSocket: ITransport + IClientConnection over System.Net.WebSockets
- SOR.Networking.Nats: IEventBus over NATS.Net (INatsConnection)
- SOR.Networking.Redis: IClientPush over Redis Pub/Sub
- SOR.Shared: ServiceResult<T>, RedisKeys, NatsSubjects, ServerMessage, JSON serializer
- SOR.Shared.Proto: auth.proto with gRPC AuthService contract
- SOR.Gateway: accept loop, auth handshake, dispatcher, Redis push subscriber
- SOR.Auth: stub gRPC handler (placeholder responses)
- SOR.Host: multi-service runner via ENABLED_SERVICES env var; wires all DI

All concrete implementations are wired exclusively in SOR.Host — every transport,
broker, and push implementation can be swapped by changing only Program.cs.

dotnet build SOR.slnx → 0 errors, 0 warnings

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-24 21:01:38 -05:00
co-authored by Claude Happy
parent 0f95a0721b
commit d21adbc8d0
52 changed files with 3522 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
namespace SOR.Gateway;
/// <summary>
/// Configuration options for the Gateway service.
/// Bound from the "Gateway" section of appsettings.json.
///
/// appsettings.json example:
/// {
/// "Gateway": {
/// "AuthTimeoutMs": 10000,
/// "MaxMessagesPerSecond": 20
/// }
/// }
/// </summary>
public sealed class GatewayOptions
{
/// <summary>
/// How long the Gateway waits for an auth.hello message after a connection is accepted.
/// If the client does not send auth.hello within this window, the connection is closed
/// with an "auth_timeout" reason.
/// Default: 10 seconds.
/// </summary>
public int AuthTimeoutMs { get; set; } = 10_000;
/// <summary>
/// Maximum number of messages per second the Gateway will process per connection.
/// Connections exceeding this rate receive a "rate_limit_exceeded" error and are
/// disconnected. Protects against runaway clients flooding the server.
///
/// Note: rate limiting is tracked per connection, not per user.
/// If a user opens multiple connections they get this budget per connection.
///
/// Set to 0 to disable rate limiting (not recommended for production).
/// Default: 20 messages per second.
///
/// Implementation: tracked in ConnectionLoop but not enforced in this foundation phase.
/// This option is defined now so configuration is in place before enforcement is added.
/// </summary>
public int MaxMessagesPerSecond { get; set; } = 20;
}