From 6a5a7926e1a11d229e255995b726345b793ff611 Mon Sep 17 00:00:00 2001 From: Daniil Cherednik Date: Wed, 13 Nov 2024 14:50:15 +0100 Subject: [PATCH] Added option to get shard nodeId for describe table call --- CHANGELOG.md | 2 ++ examples/go.mod | 2 +- examples/go.sum | 4 ++-- go.mod | 2 +- go.sum | 2 ++ internal/table/session.go | 1 + table/options/models.go | 1 + table/options/options.go | 6 ++++++ 8 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e145ca02..ed73c8352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Added experimental option to get shard nodeId for describe table call + ## v3.92.1 * Added `sugar.WithUserPassword(user,password)` option for `sugar.DSN()` helper * Added `sugar.WithSecure(bool)` option for `sugar.DSN()` helper diff --git a/examples/go.mod b/examples/go.mod index 1ab55a1b8..939c841e2 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -51,7 +51,7 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/syndtr/goleveldb v1.0.0 // indirect github.com/yandex-cloud/go-genproto v0.0.0-20220815090733-4c139c0154e2 // indirect - github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b // indirect + github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 // indirect github.com/ydb-platform/ydb-go-yc-metadata v0.6.1 // indirect golang.org/x/crypto v0.24.0 // indirect golang.org/x/mod v0.17.0 // indirect diff --git a/examples/go.sum b/examples/go.sum index 530a5d92c..2cc93e36c 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -1840,8 +1840,8 @@ github.com/ydb-platform/gorm-driver v0.1.3 h1:uewwScbRuCixNPC0LF7gDKvWcB13/iLj76 github.com/ydb-platform/gorm-driver v0.1.3/go.mod h1:49cSoG5J18muQTiKj4StL2dHs1/dB94OitnHOvetK24= github.com/ydb-platform/xorm v0.0.3 h1:MXk42lANB6r/MMLg/XdJfyXJycGUDlCeLiMlLGDKVPw= github.com/ydb-platform/xorm v0.0.3/go.mod h1:hFsU7EUF0o3S+l5c0eyP2yPVjJ0d4gsFdqCsyazzwBc= -github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b h1:8yiv/W+1xTdifJh1Stkck0gFJjys9kg0/r86Buljuss= -github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= +github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 h1:LY6cI8cP4B9rrpTleZk95+08kl2gF4rixG7+V/dwL6Q= +github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= github.com/ydb-platform/ydb-go-sdk-auth-environ v0.3.0 h1:JxSvw+Moont8qCmibP2MjSEIHfkWJLkw0fHZemAk+d0= github.com/ydb-platform/ydb-go-sdk-auth-environ v0.3.0/go.mod h1:YzCPoNrTbrXZg9bO2YkbjI6eQLkaRIE9Bq8ponu0g8A= github.com/ydb-platform/ydb-go-sdk-prometheus/v2 v2.0.1 h1:Lsir3AC2VQOTlp8UjZY9zQdCVfWvBNHT3hZn+jSGoo0= diff --git a/go.mod b/go.mod index d644d4e82..3dee26810 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/golang-jwt/jwt/v4 v4.4.1 github.com/google/uuid v1.6.0 github.com/jonboulle/clockwork v0.3.0 - github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b + github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 golang.org/x/net v0.23.0 golang.org/x/sync v0.6.0 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 diff --git a/go.sum b/go.sum index 2545222ec..2a541b379 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,8 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b h1:8yiv/W+1xTdifJh1Stkck0gFJjys9kg0/r86Buljuss= github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= +github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 h1:LY6cI8cP4B9rrpTleZk95+08kl2gF4rixG7+V/dwL6Q= +github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= diff --git a/internal/table/session.go b/internal/table/session.go index 77598ab17..6c7bff42a 100644 --- a/internal/table/session.go +++ b/internal/table/session.go @@ -418,6 +418,7 @@ func processTableStats(resStats *Ydb_Table.TableStats) *options.TableStats { for i, v := range resStats.GetPartitionStats() { partStats[i].RowsEstimate = v.GetRowsEstimate() partStats[i].StoreSize = v.GetStoreSize() + partStats[i].LeaderNodeID = v.GetLeaderNodeId() } var creationTime, modificationTime time.Time diff --git a/table/options/models.go b/table/options/models.go index eb875e63d..dcf5ab947 100644 --- a/table/options/models.go +++ b/table/options/models.go @@ -73,6 +73,7 @@ type TableStats struct { type PartitionStats struct { RowsEstimate uint64 StoreSize uint64 + LeaderNodeID uint32 } type ColumnFamily struct { diff --git a/table/options/options.go b/table/options/options.go index 922333a17..8d3f64fd2 100644 --- a/table/options/options.go +++ b/table/options/options.go @@ -28,6 +28,12 @@ func WithPartitionStats() DescribeTableOption { } } +func WithShardNodesInfo() DescribeTableOption { + return func(d *DescribeTableDesc) { + d.IncludeShardNodesInfo = true + } +} + type ( CreateTableDesc Ydb_Table.CreateTableRequest CreateTableOption interface {