Skip to content

Commit 749095b

Browse files
committed
Change wording and clean up structs in cmd files
Signed-off-by: Corey Boornazian <coreyb220@gmail.com>
1 parent f252691 commit 749095b

File tree

5 files changed

+19
-27
lines changed

5 files changed

+19
-27
lines changed

examples/hotrod/cmd/customer.go

-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ var customerCmd = &cobra.Command{
4949
var (
5050
customerOptions struct {
5151
serverInterface string
52-
serverPort int
5352
}
5453
)
5554

5655
func init() {
5756
RootCmd.AddCommand(customerCmd)
5857

5958
customerCmd.Flags().StringVarP(&customerOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the Customer server will bind")
60-
customerCmd.Flags().IntVarP(&customerOptions.serverPort, "port", "p", 8081, "port on which the Customer server will listen")
6159
}

examples/hotrod/cmd/driver.go

-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ var driverCmd = &cobra.Command{
4949
var (
5050
driverOptions struct {
5151
serverInterface string
52-
serverPort int
5352
}
5453
)
5554

5655
func init() {
5756
RootCmd.AddCommand(driverCmd)
5857

5958
driverCmd.Flags().StringVarP(&driverOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the driver server will bind")
60-
driverCmd.Flags().IntVarP(&driverOptions.serverPort, "port", "p", 8082, "port on which the driver server will listen")
6159
}

examples/hotrod/cmd/frontend.go

-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ var frontendCmd = &cobra.Command{
4747
var (
4848
frontendOptions struct {
4949
serverInterface string
50-
serverPort int
5150
}
5251
)
5352

5453
func init() {
5554
RootCmd.AddCommand(frontendCmd)
5655

5756
frontendCmd.Flags().StringVarP(&frontendOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the frontend server will bind")
58-
frontendCmd.Flags().IntVarP(&frontendOptions.serverPort, "port", "p", 8080, "port on which the frontend server will listen")
5957
}

examples/hotrod/cmd/root.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ var (
3939
fixDBConnDisableMutex bool
4040
fixRouteWorkerPoolSize int
4141

42-
fixCustomerPort int
43-
fixDriverPort int
44-
fixFrontendPort int
45-
fixRoutePort int
42+
customerPort int
43+
driverPort int
44+
frontendPort int
45+
routePort int
4646
)
4747

4848
// RootCmd represents the base command when called without any subcommands
@@ -69,10 +69,10 @@ func init() {
6969
RootCmd.PersistentFlags().IntVarP(&fixRouteWorkerPoolSize, "fix-route-worker-pool-size", "W", 3, "Default worker pool size")
7070

7171
// Add flags to choose ports for services
72-
RootCmd.PersistentFlags().IntVarP(&fixCustomerPort, "set-customer-service-port", "c", 8081, "Set port for customer service")
73-
RootCmd.PersistentFlags().IntVarP(&fixDriverPort, "set-driver-service-port", "d", 8082, "Set port for driver service")
74-
RootCmd.PersistentFlags().IntVarP(&fixFrontendPort, "set-frontend-service-port", "f", 8080, "Set port for frontend service")
75-
RootCmd.PersistentFlags().IntVarP(&fixRoutePort, "set-route-service-port", "r", 8083, "Set port for routing service")
72+
RootCmd.PersistentFlags().IntVarP(&customerPort, "customer-service-port", "c", 8081, "Port for customer service")
73+
RootCmd.PersistentFlags().IntVarP(&driverPort, "driver-service-port", "d", 8082, "Port for driver service")
74+
RootCmd.PersistentFlags().IntVarP(&frontendPort, "frontend-service-port", "f", 8080, "Port for frontend service")
75+
RootCmd.PersistentFlags().IntVarP(&routePort, "route-service-port", "r", 8083, "Port for routing service")
7676

7777
rand.Seed(int64(time.Now().Nanosecond()))
7878
logger, _ = zap.NewDevelopment(zap.AddStacktrace(zapcore.FatalLevel))
@@ -103,24 +103,24 @@ func onInitialize() {
103103
config.RouteWorkerPoolSize = fixRouteWorkerPoolSize
104104
}
105105

106-
if config.CustomerPort != fixCustomerPort {
107-
logger.Info("fix: changing customer service port", zap.Int("old", config.CustomerPort), zap.Int("new", fixCustomerPort))
108-
config.CustomerPort = fixCustomerPort
106+
if config.CustomerPort != customerPort {
107+
logger.Info("changing customer service port", zap.Int("old", config.CustomerPort), zap.Int("new", customerPort))
108+
config.CustomerPort = customerPort
109109
}
110110

111-
if config.DriverPort != fixDriverPort {
112-
logger.Info("fix: changing driver service port", zap.Int("old", config.DriverPort), zap.Int("new", fixDriverPort))
113-
config.DriverPort = fixDriverPort
111+
if config.DriverPort != driverPort {
112+
logger.Info("changing driver service port", zap.Int("old", config.DriverPort), zap.Int("new", driverPort))
113+
config.DriverPort = driverPort
114114
}
115115

116-
if config.FrontendPort != fixFrontendPort {
117-
logger.Info("fix: changing frontend service port", zap.Int("old", config.FrontendPort), zap.Int("new", fixFrontendPort))
118-
config.FrontendPort = fixFrontendPort
116+
if config.FrontendPort != frontendPort {
117+
logger.Info("changing frontend service port", zap.Int("old", config.FrontendPort), zap.Int("new", frontendPort))
118+
config.FrontendPort = frontendPort
119119
}
120120

121121
if config.RoutePort != fixRoutePort {
122-
logger.Info("fix: changing route service port", zap.Int("old", config.RoutePort), zap.Int("new", fixRoutePort))
123-
config.RoutePort = fixRoutePort
122+
logger.Info("changing route service port", zap.Int("old", config.RoutePort), zap.Int("new", fixRoutePort))
123+
config.RoutePort = routePort
124124
}
125125
}
126126

examples/hotrod/cmd/route.go

-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ var routeCmd = &cobra.Command{
4747
var (
4848
routeOptions struct {
4949
serverInterface string
50-
serverPort int
5150
}
5251
)
5352

5453
func init() {
5554
RootCmd.AddCommand(routeCmd)
5655

5756
routeCmd.Flags().StringVarP(&routeOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the Route server will bind")
58-
routeCmd.Flags().IntVarP(&routeOptions.serverPort, "port", "p", 8083, "port on which the Route server will listen")
5957
}

0 commit comments

Comments
 (0)