some small fixes
This commit is contained in:
11
balancer.go
11
balancer.go
@ -71,14 +71,16 @@ type Balancer interface {
|
|||||||
// Up informs the Balancer that gRPC has a connection to the server at
|
// Up informs the Balancer that gRPC has a connection to the server at
|
||||||
// addr. It returns down which is called once the connection to addr gets
|
// addr. It returns down which is called once the connection to addr gets
|
||||||
// lost or closed.
|
// lost or closed.
|
||||||
|
// TODO: It is not clear how to construct and take advantage the meaningful error
|
||||||
|
// parameter for down. Need realistic demands to guide.
|
||||||
Up(addr Address) (down func(error))
|
Up(addr Address) (down func(error))
|
||||||
// Get gets the address of a server for the RPC corresponding to ctx.
|
// Get gets the address of a server for the RPC corresponding to ctx.
|
||||||
// i) If it returns a connected address, gRPC internals issues the RPC on the
|
// i) If it returns a connected address, gRPC internals issues the RPC on the
|
||||||
// connection to this address;
|
// connection to this address;
|
||||||
// ii) If it returns an address on which the connection is under construction
|
// ii) If it returns an address on which the connection is under construction
|
||||||
// (initiated by Notify(...)) but not connected, gRPC internals
|
// (initiated by Notify(...)) but not connected, gRPC internals
|
||||||
// * fails RPC if the RPC is fail-fast and connection is in the TransientFailure
|
// * fails RPC if the RPC is fail-fast and connection is in the TransientFailure or
|
||||||
// or Shutdown state;
|
// Shutdown state;
|
||||||
// or
|
// or
|
||||||
// * issues RPC on the connection otherwise.
|
// * issues RPC on the connection otherwise.
|
||||||
// iii) If it returns an address on which the connection does not exist, gRPC
|
// iii) If it returns an address on which the connection does not exist, gRPC
|
||||||
@ -92,7 +94,10 @@ type Balancer interface {
|
|||||||
// instead of blocking.
|
// instead of blocking.
|
||||||
//
|
//
|
||||||
// The function returns put which is called once the rpc has completed or failed.
|
// The function returns put which is called once the rpc has completed or failed.
|
||||||
// put can collect and report RPC stats to a remote load balancer.
|
// put can collect and report RPC stats to a remote load balancer. gRPC internals
|
||||||
|
// will try to call this again if err is non-nil (unless err is ErrClientConnClosing).
|
||||||
|
//
|
||||||
|
// TODO: Add other non-recoverable errors?
|
||||||
Get(ctx context.Context, opts BalancerGetOptions) (addr Address, put func(), err error)
|
Get(ctx context.Context, opts BalancerGetOptions) (addr Address, put func(), err error)
|
||||||
// Notify returns a channel that is used by gRPC internals to watch the addresses
|
// Notify returns a channel that is used by gRPC internals to watch the addresses
|
||||||
// gRPC needs to connect. The addresses might be from a name resolver or remote
|
// gRPC needs to connect. The addresses might be from a name resolver or remote
|
||||||
|
@ -301,12 +301,7 @@ type ClientConn struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) lbWatcher() {
|
func (cc *ClientConn) lbWatcher() {
|
||||||
for {
|
for addrs := range cc.balancer.Notify() {
|
||||||
addrs, ok := <-cc.balancer.Notify()
|
|
||||||
if !ok {
|
|
||||||
// cc has been closed.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var (
|
var (
|
||||||
add []Address // Addresses need to setup connections.
|
add []Address // Addresses need to setup connections.
|
||||||
del []*addrConn // Connections need to tear down.
|
del []*addrConn // Connections need to tear down.
|
||||||
|
Reference in New Issue
Block a user