Rename the package from client/rpc_proxy to client/rpcproxy

Also rename `NewRpcProxy()` to just `New()` to avoid package stutter.
This commit is contained in:
Sean Chittenden
2016-05-26 16:15:40 -07:00
parent 22bd2b5ef2
commit 7cdf0edcfe
7 changed files with 18 additions and 18 deletions

View File

@@ -21,7 +21,7 @@ import (
"github.com/hashicorp/nomad/client/consul"
"github.com/hashicorp/nomad/client/driver"
"github.com/hashicorp/nomad/client/fingerprint"
"github.com/hashicorp/nomad/client/rpc_proxy"
"github.com/hashicorp/nomad/client/rpcproxy"
"github.com/hashicorp/nomad/client/stats"
"github.com/hashicorp/nomad/nomad"
"github.com/hashicorp/nomad/nomad/structs"
@@ -131,7 +131,7 @@ type Client struct {
logger *log.Logger
rpcProxy *rpc_proxy.RpcProxy
rpcProxy *rpcproxy.RpcProxy
connPool *nomad.ConnPool
@@ -208,7 +208,7 @@ func NewClient(cfg *config.Config) (*Client, error) {
// Create the RPC Proxy and bootstrap with the preconfigured list of
// static servers
c.rpcProxy = rpc_proxy.NewRpcProxy(c.logger, c.shutdownCh, c, c.connPool)
c.rpcProxy = rpcproxy.New(c.logger, c.shutdownCh, c, c.connPool)
for _, serverAddr := range c.config.Servers {
c.rpcProxy.AddPrimaryServer(serverAddr)
}
@@ -1396,6 +1396,6 @@ func (c *Client) emitStats(hStats *stats.HostStats) {
}
}
func (c *Client) RpcProxy() *rpc_proxy.RpcProxy {
func (c *Client) RpcProxy() *rpcproxy.RpcProxy {
return c.rpcProxy
}

View File

@@ -6,7 +6,7 @@
//
// The servers package does not provide any external API guarantees and
// should be called only by `hashicorp/nomad`.
package rpc_proxy
package rpcproxy
import (
"fmt"
@@ -303,8 +303,8 @@ func (p *RpcProxy) LeaderAddr() string {
return p.leaderAddr
}
// NewRpcProxy is the only way to safely create a new RpcProxy.
func NewRpcProxy(logger *log.Logger, shutdownCh chan struct{}, configInfo NomadConfigInfo, connPoolPinger Pinger) (p *RpcProxy) {
// New is the only way to safely create a new RpcProxy.
func New(logger *log.Logger, shutdownCh chan struct{}, configInfo NomadConfigInfo, connPoolPinger Pinger) (p *RpcProxy) {
p = new(RpcProxy)
p.logger = logger
p.configInfo = configInfo // can't pass *nomad.Client: import cycle

View File

@@ -1,4 +1,4 @@
package rpc_proxy
package rpcproxy
import (
"bytes"
@@ -57,7 +57,7 @@ func (s *fauxSerf) RPCVersion() int {
func testManager() (p *RpcProxy) {
logger := GetBufferedLogger()
shutdownCh := make(chan struct{})
p = NewRpcProxy(logger, shutdownCh, &fauxSerf{numNodes: 16384}, &fauxConnPool{})
p = New(logger, shutdownCh, &fauxSerf{numNodes: 16384}, &fauxConnPool{})
return p
}
@@ -65,7 +65,7 @@ func testManagerFailProb(failPct float64) (p *RpcProxy) {
logger := GetBufferedLogger()
logger = log.New(os.Stderr, "", log.LstdFlags)
shutdownCh := make(chan struct{})
p = NewRpcProxy(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{failPct: failPct})
p = New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{failPct: failPct})
return p
}
@@ -300,7 +300,7 @@ func TestManagerInternal_refreshServerRebalanceTimer(t *testing.T) {
shutdownCh := make(chan struct{})
for _, s := range clusters {
m := NewRpcProxy(logger, shutdownCh, &fauxSerf{numNodes: s.numNodes}, &fauxConnPool{})
m := New(logger, shutdownCh, &fauxSerf{numNodes: s.numNodes}, &fauxConnPool{})
for i := 0; i < s.numServers; i++ {
nodeName := fmt.Sprintf("s%02d", i)
m.activateEndpoint(&ServerEndpoint{Name: nodeName})

View File

@@ -1,4 +1,4 @@
package rpc_proxy_test
package rpcproxy_test
import (
"bytes"

View File

@@ -1,4 +1,4 @@
package rpc_proxy
package rpcproxy
import (
"fmt"

View File

@@ -119,7 +119,7 @@ func TestAgent_ServerConfig(t *testing.T) {
if addr := out.RPCAdvertise; addr.IP.String() != "127.0.0.1" || addr.Port != 4001 {
t.Fatalf("bad rpc advertise addr: %#v", addr)
}
if addr := a.serverHTTPAddr; addr != "10.10.11.1:4005" {
if addr := a.serverHttpAddr; addr != "10.10.11.1:4005" {
t.Fatalf("expect 10.11.11.1:4005, got: %v", addr)
}
@@ -155,7 +155,7 @@ func TestAgent_ServerConfig(t *testing.T) {
if addr := out.SerfConfig.MemberlistConfig.BindAddr; addr != "127.0.0.2" {
t.Fatalf("expect 127.0.0.2, got: %s", addr)
}
if addr := a.serverHTTPAddr; addr != "127.0.0.2:4646" {
if addr := a.serverHttpAddr; addr != "127.0.0.2:4646" {
t.Fatalf("expect 127.0.0.3:4646, got: %s", addr)
}
@@ -195,7 +195,7 @@ func TestAgent_ServerConfig(t *testing.T) {
if addr := out.SerfConfig.MemberlistConfig.BindAddr; addr != "127.0.0.3" {
t.Fatalf("expect 127.0.0.3, got: %s", addr)
}
if addr := a.serverHTTPAddr; addr != "127.0.0.3:4646" {
if addr := a.serverHttpAddr; addr != "127.0.0.3:4646" {
t.Fatalf("expect 127.0.0.3:4646, got: %s", addr)
}

View File

@@ -12,7 +12,7 @@ import (
"github.com/hashicorp/consul/tlsutil"
"github.com/hashicorp/net-rpc-msgpackrpc"
"github.com/hashicorp/nomad/client/rpc_proxy"
"github.com/hashicorp/nomad/client/rpcproxy"
"github.com/hashicorp/yamux"
)
@@ -376,7 +376,7 @@ func (p *ConnPool) RPC(region string, addr net.Addr, version int, method string,
// PingNomadServer sends a Status.Ping message to the specified server and
// returns true if healthy, false if an error occurred
func (p *ConnPool) PingNomadServer(region string, version int, s *rpc_proxy.ServerEndpoint) (bool, error) {
func (p *ConnPool) PingNomadServer(region string, version int, s *rpcproxy.ServerEndpoint) (bool, error) {
// Get a usable client
conn, sc, err := p.getClient(region, s.Addr, version)
if err != nil {