Conversation
…connect, and feature flag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Hostlink WebSocket client infrastructure with signed upgrade headers, reconnect backoff, ping/pong handling, and initial
agent.hellohandshake. This chunk does not execute websocket-delivered tasks yet.Changes
Config
WebSocketEnabled(),WebSocketURL(),WebSocketReconnectMin(),WebSocketReconnectMax(),WebSocketPingInterval()helpers inconfig/appconfSH_CONTROL_PLANE_URL(http→ws,https→wss, appends/api/v1/agents/ws)HOSTLINK_WS_ENABLED,HOSTLINK_WS_URL,HOSTLINK_WS_RECONNECT_MIN,HOSTLINK_WS_RECONNECT_MAX,HOSTLINK_WS_PING_INTERVALSigner
SignHeaders()method onRequestSignerreturnshttp.HeaderwithX-Agent-ID,X-Timestamp,X-Nonce,X-SignatureSignRequest()refactored to delegate toSignHeaders()WebSocket Client (
app/services/wsclient)Dialer/Conninterface seam for testabilitygithub.com/gorilla/websocketwith signed upgradeagent.helloimmediately on connect; marks active only afteragent.hello_ackackanderrormessages; unsupported types trigger reconnectReconnectMin/ReconnectMax)WriteControl(PingMessage, ...)Startup Wiring (
main.go)startWebSocketClientIfEnabledcalled after registrationTests
SignHeadersreturns valid signed headers with verifiable signaturesagent.hellosent immediately, active onagent.hello_ack,ackrecorded, error triggers reconnect, server close reconnects, ping failure reconnectsconfig/appconf,requestsigner,taskfetcher,taskreporterDependency
github.com/gorilla/websocket v1.5.3