CUB-200: resolve merge conflicts with dev — adopt dev's consolidated workflows and improved Go gateway code
This commit is contained in:
@@ -63,29 +63,30 @@ func main() {
|
||||
Broker: broker,
|
||||
})
|
||||
|
||||
// ── Gateway: WS primary + REST fallback ────────────────────────────────
|
||||
// WebSocket client (primary — real-time events via OpenClaw v3 protocol)
|
||||
// ── Gateway clients (WS primary, REST fallback) ───────────────────
|
||||
// WS gateway client (primary path)
|
||||
wsClient := gateway.NewWSClient(gateway.WSConfig{
|
||||
URL: cfg.WSGatewayURL,
|
||||
AuthToken: cfg.WSGatewayToken,
|
||||
}, agentRepo, broker, logger)
|
||||
|
||||
// REST polling client (fallback — only used if WS connection fails)
|
||||
restClient := gateway.NewClient(gateway.Config{
|
||||
URL: cfg.GatewayURL,
|
||||
PollInterval: cfg.GatewayPollInterval,
|
||||
// REST gateway client (fallback — only polls if WS fails to connect)
|
||||
gwClient := gateway.NewClient(gateway.Config{
|
||||
URL: cfg.GatewayRestURL,
|
||||
PollInterval: cfg.GatewayRestPollInterval,
|
||||
}, agentRepo, broker)
|
||||
|
||||
// Wire them: WS notifies REST to stand down on successful connect
|
||||
wsClient.SetRESTClient(restClient)
|
||||
// Wire them together: REST defers to WS when WS is connected
|
||||
wsClient.SetRESTClient(gwClient)
|
||||
gwClient.SetWSClient(wsClient)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Start WS client first (primary)
|
||||
go wsClient.Start(ctx)
|
||||
// Start REST client (fallback polling)
|
||||
go restClient.Start(ctx)
|
||||
// Start REST client (will wait for WS, then stand down or fall back)
|
||||
go gwClient.Start(ctx)
|
||||
|
||||
// ── Server ─────────────────────────────────────────────────────────────
|
||||
srv := &http.Server{
|
||||
|
||||
Reference in New Issue
Block a user