Skip to content

Commit c163923

Browse files
author
Chao Xu
committed
minor fixes
1 parent 2336254 commit c163923

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

cmd/agent/main.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ type GrpcProxyAgentOptions struct {
6565
proxyServerPort int
6666

6767
agentID string
68-
syncInterval int
69-
probeInterval int
70-
reconnectInterval int
68+
syncInterval time.Duration
69+
probeInterval time.Duration
70+
reconnectInterval time.Duration
7171
}
7272

7373
func (o *GrpcProxyAgentOptions) ClientSetConfig(dialOption grpc.DialOption) *agentclient.ClientSetConfig {
7474
return &agentclient.ClientSetConfig{
7575
Address: fmt.Sprintf("%s:%d", o.proxyServerHost, o.proxyServerPort),
7676
AgentID: o.agentID,
77-
SyncInterval: time.Duration(o.syncInterval) * time.Second,
78-
ProbeInterval: time.Duration(o.probeInterval) * time.Second,
79-
ReconnectInterval: time.Duration(o.reconnectInterval) * time.Second,
77+
SyncInterval: o.syncInterval,
78+
ProbeInterval: o.probeInterval,
79+
ReconnectInterval: o.reconnectInterval,
8080
DialOption: dialOption,
8181
}
8282
}
@@ -89,9 +89,9 @@ func (o *GrpcProxyAgentOptions) Flags() *pflag.FlagSet {
8989
flags.StringVar(&o.proxyServerHost, "proxy-server-host", o.proxyServerHost, "The hostname to use to connect to the proxy-server.")
9090
flags.IntVar(&o.proxyServerPort, "proxy-server-port", o.proxyServerPort, "The port the proxy server is listening on.")
9191
flags.StringVar(&o.agentID, "agent-id", o.agentID, "The unique ID of this agent. Default to a generated uuid if not set.")
92-
flags.IntVar(&o.syncInterval, "sync-interval", o.syncInterval, "The seconds by which the agent periodically checks that it has connections to all instances of the proxy server.")
93-
flags.IntVar(&o.probeInterval, "probe-interval", o.probeInterval, "The seconds by which the agent periodically checks if its connections to the proxy server are ready.")
94-
flags.IntVar(&o.reconnectInterval, "reconnect-interval", o.reconnectInterval, "The seconds by which the agent tries to reconnect.")
92+
flags.DurationVar(&o.syncInterval, "sync-interval", o.syncInterval, "The interval by which the agent periodically checks that it has connections to all instances of the proxy server.")
93+
flags.DurationVar(&o.probeInterval, "probe-interval", o.probeInterval, "The interval by which the agent periodically checks if its connections to the proxy server are ready.")
94+
flags.DurationVar(&o.reconnectInterval, "reconnect-interval", o.reconnectInterval, "The interval by which the agent tries to reconnect.")
9595
return flags
9696
}
9797

@@ -102,9 +102,9 @@ func (o *GrpcProxyAgentOptions) Print() {
102102
klog.Warningf("ProxyServerHost set to \"%s\".\n", o.proxyServerHost)
103103
klog.Warningf("ProxyServerPort set to %d.\n", o.proxyServerPort)
104104
klog.Warningf("AgentID set to %s.\n", o.agentID)
105-
klog.Warningf("SyncInterval set to %d seconds.\n", o.syncInterval)
106-
klog.Warningf("ProbeInterval set to %d.\n", o.probeInterval)
107-
klog.Warningf("ReconnectInterval set to %d.\n", o.reconnectInterval)
105+
klog.Warningf("SyncInterval set to %v.\n", o.syncInterval)
106+
klog.Warningf("ProbeInterval set to %v.\n", o.probeInterval)
107+
klog.Warningf("ReconnectInterval set to %v.\n", o.reconnectInterval)
108108
}
109109

110110
func (o *GrpcProxyAgentOptions) Validate() error {
@@ -143,9 +143,9 @@ func newGrpcProxyAgentOptions() *GrpcProxyAgentOptions {
143143
proxyServerHost: "127.0.0.1",
144144
proxyServerPort: 8091,
145145
agentID: uuid.New().String(),
146-
syncInterval: 5,
147-
probeInterval: 5,
148-
reconnectInterval: 5,
146+
syncInterval: 5 * time.Second,
147+
probeInterval: 5 * time.Second,
148+
reconnectInterval: 5 * time.Second,
149149
}
150150
return &o
151151
}

cmd/proxy/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ type ProxyRunOptions struct {
8282
// Port we listen for admin connections on.
8383
adminPort uint
8484

85-
// ID of this server.
85+
// ID of this proxy server.
8686
serverID string
87-
// Number of proxy server instances, should be 1 unless it is a HA server.
87+
// Number of proxy server instances, should be 1 unless it is a HA proxy server.
8888
serverCount uint
8989
}
9090

pkg/agent/agentclient/clientset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
type ClientSet struct {
3232
mu sync.Mutex //protects the clients.
3333
clients map[string]*AgentClient // map between serverID and the client
34-
// connects to this server.
34+
// connects to this proxy server.
3535

3636
agentID string // ID of this agent
3737
address string // proxy server address. Assuming HA proxy server

pkg/agent/agentclient/stream.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type RedialableAgentClient struct {
5555
stream agent.AgentService_ConnectClient
5656

5757
agentID string
58-
serverID string
59-
serverCount int
58+
serverID string // the id of the proxy server this client connects to.
59+
serverCount int // the number of the proxy server instances.
6060

6161
// connect opts
6262
address string
@@ -240,6 +240,7 @@ func retryLimit(serverCount int) (retries int) {
240240
return 3 + 21
241241
default:
242242
// we don't expect HA server with more than 5 instances.
243+
klog.Warningf("unexpected to handle %d proxy servers, the limit is 5.", serverCount)
243244
return 3 + 21
244245
}
245246
}

0 commit comments

Comments
 (0)