rewrite Balancer Get comments

This commit is contained in:
iamqizhao
2016-05-24 18:14:24 -07:00
parent 26c0af8adc
commit 8eab9cb6bf
2 changed files with 19 additions and 9 deletions

View File

@ -71,14 +71,24 @@ type Balancer interface {
// 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.
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.
// If opts.BlockingWait is true, it blocks if there is no connection available, // If it returns
// i.e., invocations of Up(...) is equal to those of Down(...). It respects the // i) a connected address, gRPC internals issues the RPC on the connection to
// timeout or cancellation of ctx when blocking. If opts.BlockingWait is // this address;
// false, it may return any address it has notified via Notify(...) instead of // ii) an address which is notified but not connected, gRPC internals
// blocking. The returned address may or may not be connected. The function returns // * fails RPC if the RPC is fail-fast and connection is in the TransientFailure
// put which is called once the rpc has completed or failed. put can collect and // or Shutdown state;
// report rpc stats to a remote load balancer. // * issues RPC on the connection otherwise.
// ii) an address which was not notified, gRPC internals treats it as an error
// and will fail the corresponding RPC.
//
// Therefore if opts.BlockingWait is true, it should return a connected address or
// block if there is no connected address. It respects the timeout or
// cancellation of ctx when blocking. If opts.BlockingWait is false (for fail-fast
// RPCs), it should return an address it has notified via Notify(...) immediately.
//
// 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.
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 notifies gRPC internals the list of Address to be connected. The list // Notify notifies gRPC internals the list of Address to be connected. The list
// may be from a name resolver or remote load balancer. gRPC internals will // may be from a name resolver or remote load balancer. gRPC internals will

View File

@ -139,7 +139,7 @@ func Invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
stream *transport.Stream stream *transport.Stream
put func() put func()
) )
// TODO(zhaoq): Need a formal spec of retry strategy for non-failFast rpcs. // TODO(zhaoq): Need a formal spec of fail-fast.
callHdr := &transport.CallHdr{ callHdr := &transport.CallHdr{
Host: cc.authority, Host: cc.authority,
Method: method, Method: method,