github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/retry/mode.go (about) 1 package retry 2 3 import ( 4 "github.com/ydb-platform/ydb-go-sdk/v3/internal/backoff" 5 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" 6 ) 7 8 // retryMode reports whether operation is able retried and with which properties. 9 type retryMode struct { 10 code int64 11 errType xerrors.Type 12 backoff backoff.Type 13 deleteSession bool 14 } 15 16 func (m retryMode) MustRetry(isOperationIdempotent bool) bool { 17 switch m.errType { 18 case 19 xerrors.TypeUndefined, 20 xerrors.TypeNoError, 21 xerrors.TypeNonRetryable: 22 return false 23 case xerrors.TypeConditionallyRetryable: 24 return isOperationIdempotent 25 default: 26 return true 27 } 28 } 29 30 func (m retryMode) StatusCode() int64 { return m.code } 31 32 func (m retryMode) MustBackoff() bool { return m.backoff&backoff.TypeAny != 0 } 33 34 func (m retryMode) BackoffType() backoff.Type { return m.backoff } 35 36 func (m retryMode) MustDeleteSession() bool { return m.deleteSession }