Conversation
# Conflicts: # qkc/cluster/slave/master_conn.go
# Conflicts: # qkc/cluster/slave/compat_test.go
# Conflicts: # qkc/cluster/slave/master_conn.go
# Conflicts: # qkc/cluster/slave/master_conn.go # qkc/cluster/slave/master_conn_test.go
# Conflicts: # qkc/cluster/slave/master_conn.go # qkc/cluster/slave/master_conn_test.go
# Conflicts: # qkc/cluster/slave/master_conn.go
# Conflicts: # qkc/cluster/slave/master_conn.go
# Conflicts: # qkc/cluster/slave/master_conn.go # qkc/cluster/slave/master_conn_test.go
# Conflicts: # qkc/cluster/slave/master_conn.go # qkc/cluster/slave/master_conn_test.go
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
This PR implements
PeerConn, the communication-layer abstraction for virtual peer-to-peer connections on the slave, corresponding to Python'sPeerShardConnection. APeerConnrepresents one external cluster peer on one branch. It provides typed outbound commands/RPCs, inbound dispatch through thePeerHandlerinterface, and the peer-frame routing support required inMasterConn.This PR is communication-layer only. Shard ownership, registration, creation/destruction, and cascade cleanup are intentionally left to the runtime layer.
Design
PeerConnowns no TCP socket. All traffic is tunneled through the sharedMasterConnviavirtualTransport, which stamps outbound frames with the connection's(branch, cluster_peer_id)and receives inbound frames forwarded byMasterConn.PeerConnhas its own RPC ID namespace and pending-request state, so multiple peer connections sharing oneMasterConnremain independent.PeerHandler;PeerConnitself contains no shard/business logic.PeerResolverabstracts peer lookup and branch validation, keeping peer ownership and registry management outsideMasterConn.Review Notes
cluster_peer_id == 0is rejected at construction. In the Python implementation,0is reserved for master-local traffic and is never assigned to a peer connection, butPeerShardConnectiondoes not reject it when constructed; the check only happens when writing a frame. Go validates this invariant at thePeerConnboundary instead, preventing an invalid peer connection from being created in the first place.MasterConn→PeerConncascade cleanup is intentionally not implemented here.PeerConnlifecycle ownership belongs to the runtime layer, which will handle registration, destruction, and cascade cleanup.An invalid forwarding branch closes the
MasterConn.routeFramevalidates the branch against the global configured shard set. A branch outside that set indicates an invalid frame on the master-slave channel, so the entireMasterConnis closed. A globally valid branch with no locally availablePeerConnis instead dropped, matching Python'sNULL_CONNECTIONbehavior.Python permits writes through a locally closed virtual connection; Go intentionally rejects them. This was investigated and confirmed to be a Python lifecycle/cleanup artifact rather than a protocol requirement, so the behavior is deliberately not reproduced.
Full Codex 5.6 review completed.