merge develop into developmod - #3
Merged
Merged
Conversation
Replace the per-connection managed ping loop (EnableReadTimeout + StartPingLoop, driven by each handler) with a single timeout goroutine that NewConn always starts, plus a new data-packet read timeout. libs/ws: - PingSettings (Interval, Timeout) are held in an atomic.Pointer and a separate atomic read-data-timeout; WithPingSettings/WithReadDataTimeout options on NewConn/Accept/Dial and Set* methods apply them at runtime, waking the goroutine. Negative durations are rejected. - The goroutine sends pings on the interval, and enforces the ping timeout (no pong OR data within Timeout) and the data timeout (no data within it). On expiry it stores a specific error (errReadTimeout / errReadDataTimeout) then expires the read deadline so a blocked Reader wakes and returns that error. - Activity is read from the existing stats (LastReceivedAt/LastPongAt) under statsMu with ConnectedAt as the floor -- no duplicate atomics. - Removes the bgMu/readDeadlineExt start/stop machinery; both background goroutines start in NewConn so Close just waits on them. handlers: - controller/device/worker: drop startManagedPingLoop; after registration clear the handshake deadline and apply ping (+ data, controller only) settings via a Notify watcher then the current values. Bound the handshake with a manual read deadline; use context.AfterFunc to expire the read deadline on app shutdown instead of a per-conn goroutine. config/api/docs: - Add controller data_timeout (*time.Duration so unset defaults to 2m while an explicit 0 disables it); wire through settings, /config output, example config, and API docs. Tested with go test -race -count=1000 -timeout 30m ./... (clean). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
No description provided.