Skip to content

Commit

Permalink
splitted trace.BulkUpsert{Start,Done}Info for client and session
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Oct 6, 2024
1 parent 865024a commit 0ea4a31
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
6 changes: 3 additions & 3 deletions internal/table/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, config *config.Config
return &Client{
clock: config.Clock(),
config: config,
client: Ydb_Table_V1.NewTableServiceClient(cc),
cc: cc,
build: func(ctx context.Context) (s *session, err error) {
return newSession(ctx, cc, config)
Expand Down Expand Up @@ -89,7 +88,6 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, config *config.Config
type Client struct {
// read-only fields
config *config.Config
client Ydb_Table_V1.TableServiceClient
build sessionBuilder
cc grpc.ClientConnInterface
clock clockwork.Clock
Expand Down Expand Up @@ -309,10 +307,12 @@ func (c *Client) BulkUpsert(
return xerrors.WithStackTrace(err)
}

client := Ydb_Table_V1.NewTableServiceClient(c.cc)

err = retry.Retry(ctx,
func(ctx context.Context) (err error) {
attempts++
_, err = c.client.BulkUpsert(ctx, request)
_, err = client.BulkUpsert(ctx, request)

return err
},
Expand Down
2 changes: 1 addition & 1 deletion internal/table/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ func (s *session) BulkUpsert(ctx context.Context, table string, rows value.Value
)
defer func() {
defer a.Free()
onDone(err, 1)
onDone(err)
}()

for _, opt := range opts {
Expand Down
4 changes: 3 additions & 1 deletion table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,9 @@ func BulkUpsertDataArrow(data []byte, opts ...arrowFormatOption) bulkUpsertArrow

type arrowSchemaOption []byte

func (schema arrowSchemaOption) applyArrowFormatOption(dataFormat *Ydb_Table.BulkUpsertRequest_ArrowBatchSettings) error {
func (schema arrowSchemaOption) applyArrowFormatOption(
dataFormat *Ydb_Table.BulkUpsertRequest_ArrowBatchSettings,
) error {
dataFormat.ArrowBatchSettings.Schema = schema

return nil
Expand Down
15 changes: 14 additions & 1 deletion trace/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type (
OnSessionKeepAlive func(TableKeepAliveStartInfo) func(TableKeepAliveDoneInfo)
// Query events
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionBulkUpsert func(TableBulkUpsertStartInfo) func(TableBulkUpsertDoneInfo)
OnSessionBulkUpsert func(TableSessionBulkUpsertStartInfo) func(TableSessionBulkUpsertDoneInfo)
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionQueryPrepare func(TablePrepareDataQueryStartInfo) func(TablePrepareDataQueryDoneInfo)
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
Expand Down Expand Up @@ -151,6 +151,19 @@ type (
Attempts int
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
TableSessionBulkUpsertStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
// Warning: concurrent access to pointer on client side must be excluded.
// Safe replacement of context are provided only inside callback function
Context *context.Context
Call call
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
TableSessionBulkUpsertDoneInfo struct {
Error error
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
TableSessionDeleteStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand Down
21 changes: 10 additions & 11 deletions trace/table_gtrace.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0ea4a31

Please sign in to comment.