Coding style changes to better aling with common
practice
Change-Id: I826bc614da347bf7f36a80ecb3b21caa660ffca4
diff --git a/afrouter/afrouter/affinity-router.go b/afrouter/afrouter/affinity-router.go
index eeb4df3..2b5a640 100644
--- a/afrouter/afrouter/affinity-router.go
+++ b/afrouter/afrouter/affinity-router.go
@@ -97,7 +97,7 @@
// This has already been validated bfore this function
// is called so just use it.
- for idx := range(rTypeNames) {
+ for idx := range rTypeNames {
if config.Type == rTypeNames[idx] {
dr.routerType = idx
break
@@ -125,25 +125,25 @@
field string
}
var msgs map[key]byte = make(map[key]byte)
- for _,f := range(dr.protoDescriptor.File) {
+ for _,f := range dr.protoDescriptor.File {
// Build a temporary map of message types by name.
- for _,m := range(f.MessageType) {
- for _,fld := range(m.Field) {
+ for _,m := range f.MessageType {
+ for _,fld := range m.Field {
log.Debugf("Processing message '%s', field '%s'", *m.Name, *fld.Name)
msgs[key{*m.Name, *fld.Name}] = byte(*fld.Number)
}
}
}
log.Debugf("The map contains: %v", msgs)
- for _,f := range(dr.protoDescriptor.File) {
+ for _,f := range dr.protoDescriptor.File {
if *f.Package == rconf.ProtoPackage {
- for _, s:= range(f.Service) {
+ for _, s:= range f.Service {
if *s.Name == rconf.ProtoService {
log.Debugf("Loading package data '%s' for service '%s' for router '%s'", *f.Package, *s.Name, dr.name)
// Now create a map keyed by method name with the value being the
// field number of the route selector.
var ok bool
- for _,m := range(s.Method) {
+ for _,m := range s.Method {
// Find the input type in the messages and extract the
// field number and save it for future reference.
log.Debugf("Processing method '%s'",*m.Name)
diff --git a/afrouter/afrouter/arproxy.go b/afrouter/afrouter/arproxy.go
index af5fa0f..b2fc190 100644
--- a/afrouter/afrouter/arproxy.go
+++ b/afrouter/afrouter/arproxy.go
@@ -48,7 +48,7 @@
func NewArouterProxy(conf *Configuration) (*ArouterProxy, error) {
arProxy = &ArouterProxy{servers:make(map[string]*server)}
// Create all the servers listed in the configuration
- for _,s := range(conf.Servers) {
+ for _,s := range conf.Servers {
if ns, err := NewServer(&s); err != nil {
log.Error("Configuration failed")
return nil, err
diff --git a/afrouter/afrouter/backend.go b/afrouter/afrouter/backend.go
index 1c9129e..6c97bb6 100644
--- a/afrouter/afrouter/backend.go
+++ b/afrouter/afrouter/backend.go
@@ -136,7 +136,7 @@
bClusters[bc.name] = bc
bc.startSerialNumberSource() // Serial numberere for active/active backends
idx := 0
- for _, bec := range(conf.Backends) {
+ for _, bec := range conf.Backends {
if bec.Name == "" {
log.Errorf("A backend must have a name in cluster %s\n", conf.Name)
rtrn_err = true
@@ -512,7 +512,7 @@
var rtrn error
atLeastOne := false
- for _,strm := range(strms.strms) {
+ for _,strm := range strms.strms {
if strm != nil {
if err := strm.strm.SendMsg(f); err != nil {
strm.s2cRtrn = err
@@ -523,7 +523,7 @@
// If one of the streams succeeded, declare success
// if none did pick an error and return it.
if atLeastOne == true {
- for _,strm := range(strms.strms) {
+ for _,strm := range strms.strms {
if strm != nil {
rtrn = strm.s2cRtrn
if rtrn == nil {
@@ -605,7 +605,7 @@
// Connections can consist of just a name. This allows for dynamic configuration
// at a later time.
// TODO: validate that there is one connection for all but active/active backends
- for _,cnConf := range(conf.Connections) {
+ for _,cnConf := range conf.Connections {
if cnConf.Name == "" {
log.Errorf("A connection must have a name for backend %s in cluster %s",
conf.Name, clusterName)
diff --git a/afrouter/afrouter/binding-router.go b/afrouter/afrouter/binding-router.go
index 910e6a1..45e9a27 100644
--- a/afrouter/afrouter/binding-router.go
+++ b/afrouter/afrouter/binding-router.go
@@ -203,7 +203,7 @@
// This has already been validated bfore this function
// is called so just use it.
- for idx := range(rTypeNames) {
+ for idx := range rTypeNames {
if config.Type == rTypeNames[idx] {
br.routerType = idx
break
diff --git a/afrouter/afrouter/helpers.go b/afrouter/afrouter/helpers.go
index 04d5878..6235337 100644
--- a/afrouter/afrouter/helpers.go
+++ b/afrouter/afrouter/helpers.go
@@ -18,7 +18,7 @@
package afrouter
func strIndex(ar []string, match string) int {
- for idx := range(ar) {
+ for idx := range ar {
if ar[idx] == match {
return idx
}
diff --git a/afrouter/afrouter/method-router.go b/afrouter/afrouter/method-router.go
index 7ba175d..8394c60 100644
--- a/afrouter/afrouter/method-router.go
+++ b/afrouter/afrouter/method-router.go
@@ -39,7 +39,7 @@
if len(config.Routes) == 0 {
return nil, errors.New(fmt.Sprintf("Router %s must have at least one route", config.Name))
}
- for _,rtv := range(config.Routes) {
+ for _,rtv := range config.Routes {
var idx1 string
r,err := newRouter(config, &rtv)
if err != nil {
@@ -71,7 +71,7 @@
}
}
default:
- for _,m := range(rtv.Methods) {
+ for _,m := range rtv.Methods {
log.Debugf("Setting router '%s' for method '%s'",r.Name(),m)
if _,ok := mr.mthdRt[idx1][m]; ok == false {
mr.mthdRt[idx1][m] = r
@@ -107,7 +107,7 @@
}
// Determine if one of the method routing keys exists in the metadata
- for k,_ := range(mr.mthdRt) {
+ for k,_ := range mr.mthdRt {
if _,ok := md[k]; ok == true {
rtrnV = md[k][0]
rtrnK = k
diff --git a/afrouter/afrouter/round-robin-router.go b/afrouter/afrouter/round-robin-router.go
index 2ab8421..02df6ac 100644
--- a/afrouter/afrouter/round-robin-router.go
+++ b/afrouter/afrouter/round-robin-router.go
@@ -64,7 +64,7 @@
// This has already been validated bfore this function
// is called so just use it.
- for idx := range(rTypeNames) {
+ for idx := range rTypeNames {
if config.Type == rTypeNames[idx] {
rr.routerType = idx
break
diff --git a/afrouter/afrouter/router.go b/afrouter/afrouter/router.go
index 950ccc2..7b0576e 100644
--- a/afrouter/afrouter/router.go
+++ b/afrouter/afrouter/router.go
@@ -57,32 +57,28 @@
func newRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
idx := strIndex(rTypeNames, config.Type)
- //for idx := range(rTypeNames) {
- //if config.Type == rTypeNames[idx] {
- switch idx {
- case RT_RPC_AFFINITY_MESSAGE:
- r,err := NewAffinityRouter(rconf, config)
- if err == nil {
- allRouters[rconf.Name+config.Name] = r
- }
- return r, err
- case RT_BINDING:
- r,err := NewBindingRouter(rconf, config)
- if err == nil {
- allRouters[rconf.Name+config.Name] = r
- }
- return r, err
- case RT_ROUND_ROBIN:
- r,err := NewRoundRobinRouter(rconf, config)
- if err == nil {
- allRouters[rconf.Name+config.Name] = r
- }
- return r, err
- default:
- return nil, errors.New(fmt.Sprintf("Internal error, undefined router type: %s", config.Type))
- }
+ switch idx {
+ case RT_RPC_AFFINITY_MESSAGE:
+ r,err := NewAffinityRouter(rconf, config)
+ if err == nil {
+ allRouters[rconf.Name+config.Name] = r
+ }
+ return r, err
+ case RT_BINDING:
+ r,err := NewBindingRouter(rconf, config)
+ if err == nil {
+ allRouters[rconf.Name+config.Name] = r
+ }
+ return r, err
+ case RT_ROUND_ROBIN:
+ r,err := NewRoundRobinRouter(rconf, config)
+ if err == nil {
+ allRouters[rconf.Name+config.Name] = r
+ }
+ return r, err
+ default:
+ return nil, errors.New(fmt.Sprintf("Internal error, undefined router type: %s", config.Type))
+ }
- //}
- //}
return nil, errors.New(fmt.Sprintf("Unrecognized router type '%s'",config.Type))
}
diff --git a/afrouter/afrouter/server.go b/afrouter/afrouter/server.go
index 3b729f9..e2146ef 100644
--- a/afrouter/afrouter/server.go
+++ b/afrouter/afrouter/server.go
@@ -112,7 +112,7 @@
}
// Create the routers
log.Debugf("Configuring the routers for server %s", srvr.name)
- for p,r := range(config.routers) {
+ for p,r := range config.routers {
log.Debugf("Processing router %s for package %s", r.Name,p)
if dr,err := NewRouter(r); err != nil {
log.Error(err)
diff --git a/afrouter/afrouter/signals.go b/afrouter/afrouter/signals.go
index c550842..b178b9a 100644
--- a/afrouter/afrouter/signals.go
+++ b/afrouter/afrouter/signals.go
@@ -75,10 +75,10 @@
}
}
}
- for _,cl := range(bClusters) {
- for _, bknd := range(cl.backends) {
+ for _,cl := range bClusters {
+ for _, bknd := range cl.backends {
log.Debugf("Closing backend %s", bknd.name)
- for _,conn := range(bknd.connections) {
+ for _,conn := range bknd.connections {
log.Debugf("Closing connection %s", conn.name)
conn.close()
}
diff --git a/afrouter/arouter.go b/afrouter/arouter.go
index b25ff42..dfa9fc8 100644
--- a/afrouter/arouter.go
+++ b/afrouter/arouter.go
@@ -33,7 +33,7 @@
conf,err := afrouter.ParseCmd()
- if(err != nil) {
+ if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
@@ -47,7 +47,7 @@
// Parse the config file
err = conf.LoadConfig()
- if(err != nil) {
+ if err != nil {
log.Error(err)
return
}