Browse Source

clientv3: rename to isRepeatableStopError, isNonRepeatableStopError

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
Gyu-Ho Lee 8 years ago
parent
commit
fecd26f141
1 changed files with 7 additions and 7 deletions
  1. 7 7
      clientv3/retry.go

+ 7 - 7
clientv3/retry.go

@@ -29,7 +29,7 @@ type rpcFunc func(ctx context.Context) error
 type retryRPCFunc func(context.Context, rpcFunc) error
 type retryRPCFunc func(context.Context, rpcFunc) error
 type retryStopErrFunc func(error) bool
 type retryStopErrFunc func(error) bool
 
 
-func isReadStopError(err error) bool {
+func isRepeatableStopError(err error) bool {
 	eErr := rpctypes.Error(err)
 	eErr := rpctypes.Error(err)
 	// always stop retry on etcd errors
 	// always stop retry on etcd errors
 	if _, ok := eErr.(rpctypes.EtcdError); ok {
 	if _, ok := eErr.(rpctypes.EtcdError); ok {
@@ -40,7 +40,7 @@ func isReadStopError(err error) bool {
 	return ev.Code() != codes.Unavailable
 	return ev.Code() != codes.Unavailable
 }
 }
 
 
-func isWriteStopError(err error) bool {
+func isNonRepeatableStopError(err error) bool {
 	ev, _ := status.FromError(err)
 	ev, _ := status.FromError(err)
 	if ev.Code() != codes.Unavailable {
 	if ev.Code() != codes.Unavailable {
 		return true
 		return true
@@ -103,8 +103,8 @@ func (c *Client) newAuthRetryWrapper() retryRPCFunc {
 
 
 // RetryKVClient implements a KVClient.
 // RetryKVClient implements a KVClient.
 func RetryKVClient(c *Client) pb.KVClient {
 func RetryKVClient(c *Client) pb.KVClient {
-	repeatableRetry := c.newRetryWrapper(isReadStopError)
-	nonRepeatableRetry := c.newRetryWrapper(isWriteStopError)
+	repeatableRetry := c.newRetryWrapper(isRepeatableStopError)
+	nonRepeatableRetry := c.newRetryWrapper(isNonRepeatableStopError)
 	conn := pb.NewKVClient(c.conn)
 	conn := pb.NewKVClient(c.conn)
 	retryBasic := &retryKVClient{&nonRepeatableKVClient{conn, nonRepeatableRetry}, repeatableRetry}
 	retryBasic := &retryKVClient{&nonRepeatableKVClient{conn, nonRepeatableRetry}, repeatableRetry}
 	retryAuthWrapper := c.newAuthRetryWrapper()
 	retryAuthWrapper := c.newAuthRetryWrapper()
@@ -173,7 +173,7 @@ type retryLeaseClient struct {
 func RetryLeaseClient(c *Client) pb.LeaseClient {
 func RetryLeaseClient(c *Client) pb.LeaseClient {
 	retry := &retryLeaseClient{
 	retry := &retryLeaseClient{
 		pb.NewLeaseClient(c.conn),
 		pb.NewLeaseClient(c.conn),
-		c.newRetryWrapper(isReadStopError),
+		c.newRetryWrapper(isRepeatableStopError),
 	}
 	}
 	return &retryLeaseClient{retry, c.newAuthRetryWrapper()}
 	return &retryLeaseClient{retry, c.newAuthRetryWrapper()}
 }
 }
@@ -226,7 +226,7 @@ type retryClusterClient struct {
 
 
 // RetryClusterClient implements a ClusterClient that uses the client's FailFast retry policy.
 // RetryClusterClient implements a ClusterClient that uses the client's FailFast retry policy.
 func RetryClusterClient(c *Client) pb.ClusterClient {
 func RetryClusterClient(c *Client) pb.ClusterClient {
-	return &retryClusterClient{pb.NewClusterClient(c.conn), c.newRetryWrapper(isWriteStopError)}
+	return &retryClusterClient{pb.NewClusterClient(c.conn), c.newRetryWrapper(isNonRepeatableStopError)}
 }
 }
 
 
 func (rcc *retryClusterClient) MemberAdd(ctx context.Context, in *pb.MemberAddRequest, opts ...grpc.CallOption) (resp *pb.MemberAddResponse, err error) {
 func (rcc *retryClusterClient) MemberAdd(ctx context.Context, in *pb.MemberAddRequest, opts ...grpc.CallOption) (resp *pb.MemberAddResponse, err error) {
@@ -260,7 +260,7 @@ type retryAuthClient struct {
 
 
 // RetryAuthClient implements a AuthClient that uses the client's FailFast retry policy.
 // RetryAuthClient implements a AuthClient that uses the client's FailFast retry policy.
 func RetryAuthClient(c *Client) pb.AuthClient {
 func RetryAuthClient(c *Client) pb.AuthClient {
-	return &retryAuthClient{pb.NewAuthClient(c.conn), c.newRetryWrapper(isWriteStopError)}
+	return &retryAuthClient{pb.NewAuthClient(c.conn), c.newRetryWrapper(isNonRepeatableStopError)}
 }
 }
 
 
 func (rac *retryAuthClient) AuthEnable(ctx context.Context, in *pb.AuthEnableRequest, opts ...grpc.CallOption) (resp *pb.AuthEnableResponse, err error) {
 func (rac *retryAuthClient) AuthEnable(ctx context.Context, in *pb.AuthEnableRequest, opts ...grpc.CallOption) (resp *pb.AuthEnableResponse, err error) {