P2.1: Add GatewayConnector BackgroundService with WebSocket client
- GatewayConnector: BackgroundService maintaining persistent WebSocket connection to OpenClaw Gateway with Bearer token auth from backend env only - IGatewayConnector: Interface exposing connection state, version info, health - Exponential backoff reconnect: 1s initial, max 5min, with jitter - Version pinning: RequiredVersion from config; fail-fast or warn on mismatch - Pre-flight HTTP version check before WebSocket connect - GatewayHealthController: GET /api/health/gateway with connection status - GatewayConnectorOptions: Configurable via GatewayConnector config section - Token never logged; read from Integrations:OpenClaw:Password/Token only - 16 tests: options defaults, config binding, health endpoint responses, connection states, DI registration, routing attributes
This commit is contained in:
@@ -229,6 +229,12 @@ public static class ServiceCollectionExtensions
|
||||
services.AddScoped<IStaleTaskRecoveryService, StaleTaskRecoveryService>();
|
||||
services.AddHostedService<StaleTaskRecoveryBackgroundService>();
|
||||
|
||||
// ── Gateway WebSocket Connector ──
|
||||
services.AddOptions<GatewayConnectorOptions>()
|
||||
.BindConfiguration(GatewayConnectorOptions.SectionName);
|
||||
services.AddSingleton<IGatewayConnector, GatewayConnector>();
|
||||
services.AddHostedService(sp => (GatewayConnector)sp.GetRequiredService<IGatewayConnector>());
|
||||
|
||||
// ── Backend Bridge (Agent-Command-Service) ──
|
||||
services.AddScoped<ITaskBridgeService, TaskBridgeService>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user