Skip to content

Commit

Permalink
Use local vars for flag values
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 8cef0fe commit b7d0540
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 33 deletions.
3 changes: 1 addition & 2 deletions examples/hotrod/cmd/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/log"
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/tracing"
"github.com/jaegertracing/jaeger/examples/hotrod/services/customer"
"github.com/jaegertracing/jaeger/examples/hotrod/services/config"
)

// customerCmd represents the customer command
Expand All @@ -36,7 +35,7 @@ var customerCmd = &cobra.Command{
zapLogger := logger.With(zap.String("service", "customer"))
logger := log.NewFactory(zapLogger)
server := customer.NewServer(
net.JoinHostPort(customerOptions.serverInterface, strconv.Itoa(config.CustomerPort)),
net.JoinHostPort(customerOptions.serverInterface, strconv.Itoa(customerPort)),
tracing.Init("customer", metricsFactory.Namespace("customer", nil), logger, jAgentHostPort),
metricsFactory,
logger,
Expand Down
3 changes: 1 addition & 2 deletions examples/hotrod/cmd/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/log"
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/tracing"
"github.com/jaegertracing/jaeger/examples/hotrod/services/driver"
"github.com/jaegertracing/jaeger/examples/hotrod/services/config"
)

// driverCmd represents the driver command
Expand All @@ -36,7 +35,7 @@ var driverCmd = &cobra.Command{
zapLogger := logger.With(zap.String("service", "driver"))
logger := log.NewFactory(zapLogger)
server := driver.NewServer(
net.JoinHostPort(driverOptions.serverInterface, strconv.Itoa(config.DriverPort)),
net.JoinHostPort(driverOptions.serverInterface, strconv.Itoa(driverPort)),
tracing.Init("driver", metricsFactory.Namespace("driver", nil), logger, jAgentHostPort),
metricsFactory,
logger,
Expand Down
3 changes: 1 addition & 2 deletions examples/hotrod/cmd/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/log"
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/tracing"
"github.com/jaegertracing/jaeger/examples/hotrod/services/frontend"
"github.com/jaegertracing/jaeger/examples/hotrod/services/config"
)

// frontendCmd represents the frontend command
Expand All @@ -36,7 +35,7 @@ var frontendCmd = &cobra.Command{
zapLogger := logger.With(zap.String("service", "frontend"))
logger := log.NewFactory(zapLogger)
server := frontend.NewServer(
net.JoinHostPort(frontendOptions.serverInterface, strconv.Itoa(config.FrontendPort)),
net.JoinHostPort(frontendOptions.serverInterface, strconv.Itoa(frontendPort)),
tracing.Init("frontend", metricsFactory.Namespace("frontend", nil), logger, jAgentHostPort),
logger,
)
Expand Down
20 changes: 8 additions & 12 deletions examples/hotrod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,20 @@ func onInitialize() {
config.RouteWorkerPoolSize = fixRouteWorkerPoolSize
}

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

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

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

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

Expand Down
3 changes: 1 addition & 2 deletions examples/hotrod/cmd/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/log"
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/tracing"
"github.com/jaegertracing/jaeger/examples/hotrod/services/route"
"github.com/jaegertracing/jaeger/examples/hotrod/services/config"
)

// routeCmd represents the route command
Expand All @@ -36,7 +35,7 @@ var routeCmd = &cobra.Command{
zapLogger := logger.With(zap.String("service", "route"))
logger := log.NewFactory(zapLogger)
server := route.NewServer(
net.JoinHostPort(routeOptions.serverInterface, strconv.Itoa(config.RoutePort)),
net.JoinHostPort(routeOptions.serverInterface, strconv.Itoa(routePort)),
tracing.Init("route", metricsFactory.Namespace("route", nil), logger, jAgentHostPort),
logger,
)
Expand Down
13 changes: 0 additions & 13 deletions examples/hotrod/services/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,4 @@ var (
// RouteCalcDelayStdDev is standard deviation
RouteCalcDelayStdDev = RouteCalcDelay / 4

// Port settings, can be overwritten from command line

// Customer Service Port
CustomerPort = 8081

// Driver Service Port
DriverPort = 8082

// Frontend Service Port
FrontendPort = 8080

// Routing Service Port
RoutePort = 8083
)

0 comments on commit b7d0540

Please sign in to comment.