Skip to content

Commit

Permalink
Leave options as they were
Browse files Browse the repository at this point in the history
  • Loading branch information
UgnineSirdis committed Oct 4, 2024
1 parent edfaf7f commit 327ee24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
2 changes: 1 addition & 1 deletion internal/table/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (c *Client) BulkUpsert(
finalErr = retry.Retry(ctx,
func(ctx context.Context) (err error) {
attempts++
_, err = c.client.BulkUpsert(ctx, &request, config.CallOptions...)
_, err = c.client.BulkUpsert(ctx, &request)

return err
},
Expand Down
28 changes: 0 additions & 28 deletions table/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/types"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
)

func WithShardKeyBounds() DescribeTableOption {
Expand Down Expand Up @@ -871,28 +869,6 @@ func WithKeepInCache(keepInCache bool) ExecuteDataQueryOption {
)
}

type TableOptions struct {
Label string
Idempotent bool
TxSettings *TransactionSettings
TxCommitOptions []CommitTransactionOption
RetryOptions []retry.Option
Trace *trace.Table
CallOptions []grpc.CallOption
}

type TransactionSettings struct {
settings Ydb_Table.TransactionSettings
}

func (t *TransactionSettings) Settings() *Ydb_Table.TransactionSettings {
if t == nil {
return nil
}

return &t.settings
}

type withCallOptions []grpc.CallOption

func (opts withCallOptions) ApplyExecuteScanQueryOption(d *ExecuteScanQueryDesc) []grpc.CallOption {
Expand All @@ -909,10 +885,6 @@ func (opts withCallOptions) ApplyExecuteDataQueryOption(
return opts
}

func (opts withCallOptions) ApplyTableOption(tableOpts *TableOptions) {
tableOpts.CallOptions = append(tableOpts.CallOptions, opts...)
}

// WithCallOptions appends flag of commit transaction with executing query
func WithCallOptions(opts ...grpc.CallOption) withCallOptions {
return opts
Expand Down
25 changes: 21 additions & 4 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,17 @@ type Session interface {
) error
}

type TransactionSettings = options.TransactionSettings
type TransactionSettings struct {
settings Ydb_Table.TransactionSettings
}

func (t *TransactionSettings) Settings() *Ydb_Table.TransactionSettings {
if t == nil {
return nil
}

return &t.settings
}

// Explanation is a result of Explain calls.
type Explanation struct {
Expand Down Expand Up @@ -305,7 +315,7 @@ func TxSettings(opts ...TxOption) *TransactionSettings {
s := new(TransactionSettings)
for _, opt := range opts {
if opt != nil {
opt((*txDesc)(s.Settings()))
opt((*txDesc)(&s.settings))
}
}

Expand All @@ -317,7 +327,7 @@ func BeginTx(opts ...TxOption) TxControlOption {
return func(d *txControlDesc) {
s := TxSettings(opts...)
d.TxSelector = &Ydb_Table.TransactionControl_BeginTx{
BeginTx: s.Settings(),
BeginTx: &s.settings,
}
}
}
Expand Down Expand Up @@ -488,7 +498,14 @@ func ValueParam(name string, v value.Value) ParameterOption {
return params.Named(name, v)
}

type Options = options.TableOptions
type Options struct {
Label string
Idempotent bool
TxSettings *TransactionSettings
TxCommitOptions []options.CommitTransactionOption
RetryOptions []retry.Option
Trace *trace.Table
}

type Option interface {
ApplyTableOption(opts *Options)
Expand Down

0 comments on commit 327ee24

Please sign in to comment.