From 91bcf9503b7fe69909ff02748216de50669f4ce5 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 29 Jan 2025 13:39:59 -0500 Subject: [PATCH] chore: fix field comments on ClientSet Not following the go conventions here means the wrong comments appear in IDEs. --- pkg/agent/clientset.go | 69 ++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/pkg/agent/clientset.go b/pkg/agent/clientset.go index d734420f1..e725af7cd 100644 --- a/pkg/agent/clientset.go +++ b/pkg/agent/clientset.go @@ -38,42 +38,67 @@ const ( // ClientSet consists of clients connected to each instance of an HA proxy server. type ClientSet struct { - mu sync.Mutex //protects the clients. - clients map[string]*Client // map between serverID and the client - // connects to this server. - - agentID string // ID of this agent - address string // proxy server address. Assuming HA proxy server - - leaseCounter ServerCounter // counts number of proxy server leases - lastReceivedServerCount int // last server count received from a proxy server - lastServerCount int // last server count value from either lease system or proxy server, former takes priority - - // unless it is an HA server. Initialized when the ClientSet creates - // the first client. When syncForever is set, it will be the most recently seen. - syncInterval time.Duration // The interval by which the agent - // periodically checks that it has connections to all instances of the - // proxy server. - probeInterval time.Duration // The interval by which the agent + // mu guards access to the clients map + mu sync.Mutex + + // clients is a map between serverID and the client + // connected to this server. + clients map[string]*Client + + // agentID is "our ID" - the ID of this agent. + agentID string + + // Address is the proxy server address. Assuming HA proxy server + address string + + // leaseCounter counts number of proxy server leases + leaseCounter ServerCounter + + // lastReceivedServerCount is the last serverCount value received when connecting to a proxy server + lastReceivedServerCount int + + // lastServerCount is the most-recently observed serverCount value from either lease system or proxy server, + // former takes priority unless it is an HA server. + // Initialized when the ClientSet creates the first client. + // When syncForever is set, it will be the most recently seen. + lastServerCount int + + // syncInterval is the interval at which the agent periodically checks + // that it has connections to all instances of the proxy server. + syncInterval time.Duration + + // The maximum interval for the syncInterval to back off to when unable to connect to the proxy server + syncIntervalCap time.Duration + + // syncForever is true if we should continue syncing (support dynamic server count). + syncForever bool + + // probeInterval is the interval at which the agent // periodically checks if its connections to the proxy server is ready. - syncIntervalCap time.Duration // The maximum interval - // for the syncInterval to back off to when unable to connect to the proxy server + probeInterval time.Duration dialOptions []grpc.DialOption - // file path contains service account token + + // serviceAccountTokenPath is the file path to our kubernetes service account token serviceAccountTokenPath string + // channel to signal that the agent is pending termination. drainCh <-chan struct{} + // channel to signal shutting down the client set. Primarily for test. stopCh <-chan struct{} - agentIdentifiers string // The identifiers of the agent, which will be used + // agentIdentifiers is the identifiers of the agent, which will be used // by the server when choosing agent + agentIdentifiers string warnOnChannelLimit bool xfrChannelSize int - syncForever bool // Continue syncing (support dynamic server count). + // serverCountSource controls how we compute the server count. + // The proxy server sends the serverCount header to each connecting agent, + // and the agent figures out from these observations how many + // agent-to-proxy-server connections it should maintain. serverCountSource string }