github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/query/client.go (about)

     1  package query
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/closer"
     7  	"github.com/ydb-platform/ydb-go-sdk/v3/retry"
     8  	"github.com/ydb-platform/ydb-go-sdk/v3/trace"
     9  )
    10  
    11  type Client interface {
    12  	// Do provide the best effort for execute operation.
    13  	//
    14  	// Do implements internal busy loop until one of the following conditions is met:
    15  	// - deadline was canceled or deadlined
    16  	// - retry operation returned nil as error
    17  	//
    18  	// Warning: if context without deadline or cancellation func than Do can run indefinitely.
    19  	Do(ctx context.Context, op Operation, opts ...DoOption) error
    20  
    21  	// DoTx provide the best effort for execute transaction.
    22  	//
    23  	// DoTx implements internal busy loop until one of the following conditions is met:
    24  	// - deadline was canceled or deadlined
    25  	// - retry operation returned nil as error
    26  	//
    27  	// DoTx makes auto selector (with TransactionSettings, by default - SerializableReadWrite), commit and
    28  	// rollback (on error) of transaction.
    29  	//
    30  	// If op TxOperation returns nil - transaction will be committed
    31  	// If op TxOperation return non nil - transaction will be rollback
    32  	// Warning: if context without deadline or cancellation func than DoTx can run indefinitely
    33  	DoTx(ctx context.Context, op TxOperation, opts ...DoTxOption) error
    34  }
    35  
    36  type (
    37  	// Operation is the interface that holds an operation for retry.
    38  	// if Operation returns not nil - operation will retry
    39  	// if Operation returns nil - retry loop will break
    40  	Operation func(ctx context.Context, s Session) error
    41  
    42  	// TxOperation is the interface that holds an operation for retry.
    43  	// if TxOperation returns not nil - operation will retry
    44  	// if TxOperation returns nil - retry loop will break
    45  	TxOperation func(ctx context.Context, tx TxActor) error
    46  
    47  	ClosableSession interface {
    48  		closer.Closer
    49  
    50  		Session
    51  	}
    52  
    53  	DoOption interface {
    54  		applyDoOption(o *DoOptions)
    55  	}
    56  
    57  	DoOptions struct {
    58  		Label        string
    59  		Idempotent   bool
    60  		RetryOptions []retry.Option
    61  		Trace        *trace.Query
    62  	}
    63  
    64  	DoTxOption interface {
    65  		applyDoTxOption(o *DoTxOptions)
    66  	}
    67  
    68  	DoTxOptions struct {
    69  		DoOptions
    70  
    71  		TxSettings TransactionSettings
    72  	}
    73  )