Repository navigation
refactor: move the connection code into transport.go - #43
Merged
Merged
Conversation
ilyam8
added this pull request to stack #38
October 9, 2026 15:18
ilyam8
force-pushed
the
engine-transport
branch
2 times, most recently
from
October 11, 2026 09:46
b05b8d1 to
2d7cffe
Compare
Mutation probes on the connection code found it unpinned by the unit tests: the engine harness builds clients without Connect and the Close tests build only with the end2end tag. TestConnect pins, on loopback sockets, the network Connect, ConnectIPv4 and ConnectIPv6 choose (udp4/tcp4 for an IPv4 local address; known bug: a second ConnectIPv4 dials "udp44"), the validation before dialing, the error wrapping, the Control hook, the local address, the dial timeout (Unix) and the context. TestCloseOnce pins that Close returns the connection's error, clears it and does nothing the second time. Both pass on the current code.
Connect, ConnectIPv4, ConnectIPv6, Close, connect, netConnect and receive move from gosnmp.go and marshal.go into transport.go unchanged, and the write branch of sendOneRequest (WriteTo on an unconnected UDP socket, Write otherwise) becomes write there. The exported fields stay where they are. No behavior change: every golden, TestConnect and TestCloseOnce unchanged.
ilyam8
force-pushed
the
engine-transport
branch
from
October 11, 2026 09:52
2d7cffe to
eec268f
Compare
vkalintiris
approved these changes
Oct 11, 2026
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
Second restructuring step of the request engine: the connection code in one file. No behavior or exported API change; the exported connection fields stay on
GoSNMP.transport.go:Connect,ConnectIPv4,ConnectIPv6,Close,connect,netConnectandreceivemove fromgosnmp.goandmarshal.gounchanged. The write branch ofsendOneRequest(WriteToon an unconnected UDP socket,Writeotherwise) becomeswritethere.The first commit pins the connection setup, which the unit tests did not observe (the engine harness builds clients without
Connect, and theClosetests build only with theend2endtag).TestConnectpins, on loopback sockets, the network eachConnect*chooses (udp4/tcp4 for an IPv4 local address; known bug: a secondConnectIPv4dialsudp44), the validation before dialing, the error wrapping, theControlhook, the local address, the dial timeout (skipped on Windows, whose UDP dial does not check the context after connecting) and the context.TestCloseOncepins thatClosereturns the connection's error, clears it and does nothing the second time. Both pass on the previous code.Testing
go test ./...on darwin/arm64 andGOARCH=386;-race;GOOS=windows go vet; the FIPS 140-only tests; golangci-lint v2.14.0 (incl.end2end): 0 issues.transport.go: 21 caught, 1 equivalent (reusing the receive buffer acrossConnects:receivecopies out and never reads stale bytes).BenchmarkSendOneRequest, interleaved A/B, 6 rounds: time unchanged (p = 1.000), B/op and allocs/op identical.