Skip to content

Commit

Permalink
Change wording and clean up structs in cmd files
Browse files Browse the repository at this point in the history
Signed-off-by: Corey Boornazian <coreyb220@gmail.com>
  • Loading branch information
cboornaz17 committed Jul 24, 2018
1 parent f252691 commit 749095b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
2 changes: 0 additions & 2 deletions examples/hotrod/cmd/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ var customerCmd = &cobra.Command{
var (
customerOptions struct {
serverInterface string
serverPort int
}
)

func init() {
RootCmd.AddCommand(customerCmd)

customerCmd.Flags().StringVarP(&customerOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the Customer server will bind")
customerCmd.Flags().IntVarP(&customerOptions.serverPort, "port", "p", 8081, "port on which the Customer server will listen")
}
2 changes: 0 additions & 2 deletions examples/hotrod/cmd/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ var driverCmd = &cobra.Command{
var (
driverOptions struct {
serverInterface string
serverPort int
}
)

func init() {
RootCmd.AddCommand(driverCmd)

driverCmd.Flags().StringVarP(&driverOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the driver server will bind")
driverCmd.Flags().IntVarP(&driverOptions.serverPort, "port", "p", 8082, "port on which the driver server will listen")
}
2 changes: 0 additions & 2 deletions examples/hotrod/cmd/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ var frontendCmd = &cobra.Command{
var (
frontendOptions struct {
serverInterface string
serverPort int
}
)

func init() {
RootCmd.AddCommand(frontendCmd)

frontendCmd.Flags().StringVarP(&frontendOptions.serverInterface, "bind", "", "0.0.0.0", "interface to which the frontend server will bind")
frontendCmd.Flags().IntVarP(&frontendOptions.serverPort, "port", "p", 8080, "port on which the frontend server will listen")
}
38 changes: 19 additions & 19 deletions examples/hotrod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ var (
fixDBConnDisableMutex bool
fixRouteWorkerPoolSize int

fixCustomerPort int
fixDriverPort int
fixFrontendPort int
fixRoutePort int
customerPort int
driverPort int
frontendPort int
routePort int
)

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

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

rand.Seed(int64(time.Now().Nanosecond()))
logger, _ = zap.NewDevelopment(zap.AddStacktrace(zapcore.FatalLevel))
Expand Down Expand Up @@ -103,24 +103,24 @@ func onInitialize() {
config.RouteWorkerPoolSize = fixRouteWorkerPoolSize
}

if config.CustomerPort != fixCustomerPort {
logger.Info("fix: changing customer service port", zap.Int("old", config.CustomerPort), zap.Int("new", fixCustomerPort))
config.CustomerPort = fixCustomerPort
if config.CustomerPort != customerPort {
logger.Info("changing customer service port", zap.Int("old", config.CustomerPort), zap.Int("new", customerPort))
config.CustomerPort = customerPort
}

if config.DriverPort != fixDriverPort {
logger.Info("fix: changing driver service port", zap.Int("old", config.DriverPort), zap.Int("new", fixDriverPort))
config.DriverPort = fixDriverPort
if config.DriverPort != driverPort {
logger.Info("changing driver service port", zap.Int("old", config.DriverPort), zap.Int("new", driverPort))
config.DriverPort = driverPort
}

if config.FrontendPort != fixFrontendPort {
logger.Info("fix: changing frontend service port", zap.Int("old", config.FrontendPort), zap.Int("new", fixFrontendPort))
config.FrontendPort = fixFrontendPort
if config.FrontendPort != frontendPort {
logger.Info("changing frontend service port", zap.Int("old", config.FrontendPort), zap.Int("new", frontendPort))
config.FrontendPort = frontendPort
}

if config.RoutePort != fixRoutePort {
logger.Info("fix: changing route service port", zap.Int("old", config.RoutePort), zap.Int("new", fixRoutePort))
config.RoutePort = fixRoutePort
logger.Info("changing route service port", zap.Int("old", config.RoutePort), zap.Int("new", fixRoutePort))
config.RoutePort = routePort
}
}

Expand Down
2 changes: 0 additions & 2 deletions examples/hotrod/cmd/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ var routeCmd = &cobra.Command{
var (
routeOptions struct {
serverInterface string
serverPort int
}
)

func init() {
RootCmd.AddCommand(routeCmd)

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

0 comments on commit 749095b

Please sign in to comment.