Removal of exports that aren't needed, other genereal
cleanup of commented out code, and other minor changes.
Change-Id: Icb29cdc527d4c01e3a5d4d3d6de2e074745d0f33
diff --git a/afrouter/afrouter/affinity-router.go b/afrouter/afrouter/affinity-router.go
index 2b5a640..443a55e 100644
--- a/afrouter/afrouter/affinity-router.go
+++ b/afrouter/afrouter/affinity-router.go
@@ -42,7 +42,7 @@
curBknd **backend
}
-func NewAffinityRouter(rconf *RouterConfig, config *RouteConfig) (Router,error) {
+func newAffinityRouter(rconf *RouterConfig, config *RouteConfig) (Router,error) {
var err error = nil
var rtrn_err bool = false
// Validate the configuration
@@ -181,7 +181,7 @@
// Create the backend cluster or link to an existing one
ok := true
if dr.bkndClstr, ok = bClusters[config.backendCluster.Name]; ok == false {
- if dr.bkndClstr, err = NewBackendCluster(config.backendCluster); err != nil {
+ if dr.bkndClstr, err = newBackendCluster(config.backendCluster); err != nil {
log.Errorf("Could not create a backend for router %s", config.Name)
rtrn_err = true
}
diff --git a/afrouter/afrouter/api.go b/afrouter/afrouter/api.go
index dd1506f..8235525 100644
--- a/afrouter/afrouter/api.go
+++ b/afrouter/afrouter/api.go
@@ -38,7 +38,7 @@
ar *ArouterProxy
}
-func NewApi(config *ApiConfig, ar *ArouterProxy) (*ArouterApi, error) {
+func newApi(config *ApiConfig, ar *ArouterProxy) (*ArouterApi, error) {
var rtrn_err bool
// Create a seperate server and listener for the API
// Validate the ip address if one is provided
diff --git a/afrouter/afrouter/arproxy.go b/afrouter/afrouter/arproxy.go
index b2fc190..d809fbb 100644
--- a/afrouter/afrouter/arproxy.go
+++ b/afrouter/afrouter/arproxy.go
@@ -49,7 +49,7 @@
arProxy = &ArouterProxy{servers:make(map[string]*server)}
// Create all the servers listed in the configuration
for _,s := range conf.Servers {
- if ns, err := NewServer(&s); err != nil {
+ if ns, err := newServer(&s); err != nil {
log.Error("Configuration failed")
return nil, err
} else {
@@ -59,7 +59,7 @@
// TODO: The API is not mandatory, check if it's even in the config before
// trying to create it. If it isn't then don't bother but log a warning.
- if api,err := NewApi(&conf.Api, arProxy); err != nil {
+ if api,err := newApi(&conf.Api, arProxy); err != nil {
return nil, err
} else {
arProxy.api = api
diff --git a/afrouter/afrouter/backend.go b/afrouter/afrouter/backend.go
index 6c97bb6..9262d43 100644
--- a/afrouter/afrouter/backend.go
+++ b/afrouter/afrouter/backend.go
@@ -121,7 +121,7 @@
//TODO: Move the backend type (active/active etc) to the cluster
// level. All backends should really be of the same type.
// Create a new backend cluster
-func NewBackendCluster(conf *BackendClusterConfig) (*backendCluster, error) {
+func newBackendCluster(conf *BackendClusterConfig) (*backendCluster, error) {
var err error = nil
var rtrn_err bool = false
var be *backend
diff --git a/afrouter/afrouter/binding-router.go b/afrouter/afrouter/binding-router.go
index 45e9a27..a87481b 100644
--- a/afrouter/afrouter/binding-router.go
+++ b/afrouter/afrouter/binding-router.go
@@ -121,7 +121,7 @@
return nil
}
-func NewBindingRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
+func newBindingRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
var rtrn_err bool = false
var err error = nil
log.Debugf("Creating binding router %s",config.Name)
@@ -213,7 +213,7 @@
// Create the backend cluster or link to an existing one
ok := true
if br.bkndClstr, ok = bClusters[config.backendCluster.Name]; ok == false {
- if br.bkndClstr, err = NewBackendCluster(config.backendCluster); err != nil {
+ if br.bkndClstr, err = newBackendCluster(config.backendCluster); err != nil {
log.Errorf("Could not create a backend for router %s", config.Name)
rtrn_err = true
}
diff --git a/afrouter/afrouter/codec.go b/afrouter/afrouter/codec.go
index 20bf354..6090bdc 100644
--- a/afrouter/afrouter/codec.go
+++ b/afrouter/afrouter/codec.go
@@ -29,11 +29,11 @@
return CodecWithParent(&protoCodec{})
}
-func CodecWithParent(fallback grpc.Codec) grpc.Codec {
- return &rawCodec{fallback}
+func CodecWithParent(parent grpc.Codec) grpc.Codec {
+ return &transparentRoutingCodec{parent}
}
-type rawCodec struct {
+type transparentRoutingCodec struct {
parentCodec grpc.Codec
}
@@ -58,19 +58,19 @@
metaVal string
}
-func (c *rawCodec) Marshal(v interface{}) ([]byte, error) {
+func (cdc *transparentRoutingCodec) Marshal(v interface{}) ([]byte, error) {
switch t := v.(type) {
case *sbFrame:
return t.payload, nil
case *nbFrame:
return t.payload, nil
default:
- return c.parentCodec.Marshal(v)
+ return cdc.parentCodec.Marshal(v)
}
}
-func (c *rawCodec) Unmarshal(data []byte, v interface{}) error {
+func (cdc *transparentRoutingCodec) Unmarshal(data []byte, v interface{}) error {
switch t := v.(type) {
case *sbFrame:
t.payload = data
@@ -85,15 +85,15 @@
log.Debugf("Routing returned %v for method %s", t.be, t.mthdSlice[REQ_METHOD])
return nil
default:
- return c.parentCodec.Unmarshal(data,v)
+ return cdc.parentCodec.Unmarshal(data,v)
}
}
-func (c *rawCodec) String() string {
- return fmt.Sprintf("proxy>%s", c.parentCodec.String())
+func (cdc *transparentRoutingCodec) String() string {
+ return fmt.Sprintf("%s", cdc.parentCodec.String())
}
-// protoCodec is a Codec implementation with protobuf. It is the default rawCodec for gRPC.
+// protoCodec is a Codec implementation with protobuf. It is the default Codec for gRPC.
type protoCodec struct{}
func (protoCodec) Marshal(v interface{}) ([]byte, error) {
@@ -105,5 +105,5 @@
}
func (protoCodec) String() string {
- return "proto"
+ return "protoCodec"
}
diff --git a/afrouter/afrouter/method-router.go b/afrouter/afrouter/method-router.go
index 8394c60..e4824da 100644
--- a/afrouter/afrouter/method-router.go
+++ b/afrouter/afrouter/method-router.go
@@ -41,7 +41,7 @@
}
for _,rtv := range config.Routes {
var idx1 string
- r,err := newRouter(config, &rtv)
+ r,err := newSubRouter(config, &rtv)
if err != nil {
return nil, err
}
diff --git a/afrouter/afrouter/round-robin-router.go b/afrouter/afrouter/round-robin-router.go
index 02df6ac..4e81985 100644
--- a/afrouter/afrouter/round-robin-router.go
+++ b/afrouter/afrouter/round-robin-router.go
@@ -32,7 +32,7 @@
curBknd **backend
}
-func NewRoundRobinRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
+func newRoundRobinRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
var err error = nil
var rtrn_err bool = false
// Validate the configuration
@@ -74,7 +74,7 @@
// Create the backend cluster or link to an existing one
ok := true
if rr.bkndClstr, ok = bClusters[config.backendCluster.Name]; ok == false {
- if rr.bkndClstr, err = NewBackendCluster(config.backendCluster); err != nil {
+ if rr.bkndClstr, err = newBackendCluster(config.backendCluster); err != nil {
log.Errorf("Could not create a backend for router %s", config.Name)
rtrn_err = true
}
diff --git a/afrouter/afrouter/router.go b/afrouter/afrouter/router.go
index 7b0576e..f1e729f 100644
--- a/afrouter/afrouter/router.go
+++ b/afrouter/afrouter/router.go
@@ -47,7 +47,7 @@
GetMetaKeyVal(serverStream grpc.ServerStream) (string,string,error)
}
-func NewRouter(config *RouterConfig) (Router, error) {
+func newRouter(config *RouterConfig) (Router, error) {
r,err := newMethodRouter(config)
if err == nil {
allRouters[r.Name()] = r
@@ -55,23 +55,23 @@
return r, err
}
-func newRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
+func newSubRouter(rconf *RouterConfig, config *RouteConfig) (Router, error) {
idx := strIndex(rTypeNames, config.Type)
switch idx {
case RT_RPC_AFFINITY_MESSAGE:
- r,err := NewAffinityRouter(rconf, config)
+ 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)
+ 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)
+ r,err := newRoundRobinRouter(rconf, config)
if err == nil {
allRouters[rconf.Name+config.Name] = r
}
diff --git a/afrouter/afrouter/server.go b/afrouter/afrouter/server.go
index e2146ef..17c3b4f 100644
--- a/afrouter/afrouter/server.go
+++ b/afrouter/afrouter/server.go
@@ -63,7 +63,7 @@
var mthdSlicer *regexp.Regexp // The compiled regex to extract the package/service/method
-func NewServer(config *ServerConfig) (*server,error) {
+func newServer(config *ServerConfig) (*server,error) {
var err error = nil
var rtrn_err bool = false
var srvr *server
@@ -114,7 +114,7 @@
log.Debugf("Configuring the routers for server %s", srvr.name)
for p,r := range config.routers {
log.Debugf("Processing router %s for package %s", r.Name,p)
- if dr,err := NewRouter(r); err != nil {
+ if dr,err := newRouter(r); err != nil {
log.Error(err)
return nil, err
} else {