github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/table/errors.go (about)

     1  package table
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
     7  	grpcCodes "google.golang.org/grpc/codes"
     8  
     9  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
    10  )
    11  
    12  var (
    13  	errNilClient = xerrors.Wrap(errors.New("table client is not initialized"))
    14  
    15  	// errClosedClient returned by a Client instance to indicate
    16  	// that Client is closed early and not able to complete requested operation.
    17  	errClosedClient = xerrors.Wrap(errors.New("table client closed early"))
    18  
    19  	// errSessionPoolOverflow returned by a Client instance to indicate
    20  	// that the Client is full and requested operation is not able to complete.
    21  	errSessionPoolOverflow = xerrors.Wrap(errors.New("session pool overflow"))
    22  
    23  	// errSessionUnderShutdown returned by a Client instance to indicate that
    24  	// requested session is under shutdown.
    25  	errSessionUnderShutdown = xerrors.Wrap(errors.New("session under shutdown"))
    26  
    27  	// errSessionClosed returned by a Client instance to indicate that
    28  	// requested session is closed early.
    29  	errSessionClosed = xerrors.Wrap(errors.New("session closed early"))
    30  
    31  	// errNoProgress returned by a Client instance to indicate that
    32  	// operation could not be completed.
    33  	errNoProgress = xerrors.Wrap(errors.New("no progress"))
    34  
    35  	// errNodeIsNotObservable returned by a Client instance to indicate that required node is not observable
    36  	errNodeIsNotObservable = xerrors.Wrap(errors.New("node is not observable"))
    37  
    38  	// errParamsRequired returned by a Client instance to indicate that required params is not defined
    39  	errParamsRequired = xerrors.Wrap(errors.New("params required"))
    40  )
    41  
    42  func isCreateSessionErrorRetriable(err error) bool {
    43  	switch {
    44  	case
    45  		xerrors.Is(err, errSessionPoolOverflow),
    46  		xerrors.IsOperationError(err, Ydb.StatusIds_OVERLOADED),
    47  		xerrors.IsTransportError(
    48  			err,
    49  			grpcCodes.ResourceExhausted,
    50  			grpcCodes.DeadlineExceeded,
    51  			grpcCodes.Unavailable,
    52  		):
    53  		return true
    54  	default:
    55  		return false
    56  	}
    57  }