diff --git a/.golangci.yml b/.golangci.yml index aeb5039a4..a7770e46e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -224,7 +224,6 @@ linters: - dupl - exhaustive - exhaustivestruct - - exhaustruct - forbidigo - funlen - gochecknoglobals @@ -296,6 +295,7 @@ issues: - unused - unparam - gocritic + - exhaustruct - forcetypeassert - path: topic/topicreader/reader_example_test.go linters: diff --git a/balancers/balancers.go b/balancers/balancers.go index 2fe525a53..fe5ba4caf 100644 --- a/balancers/balancers.go +++ b/balancers/balancers.go @@ -13,16 +13,29 @@ import ( // Will be removed after Oct 2024. // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated func RoundRobin() *balancerConfig.Config { - return &balancerConfig.Config{} + return &balancerConfig.Config{ + Filter: nil, + AllowFallback: false, + SingleConn: false, + DetectLocalDC: false, + } } func RandomChoice() *balancerConfig.Config { - return &balancerConfig.Config{} + return &balancerConfig.Config{ + Filter: nil, + AllowFallback: false, + SingleConn: false, + DetectLocalDC: false, + } } func SingleConn() *balancerConfig.Config { return &balancerConfig.Config{ - SingleConn: true, + Filter: nil, + AllowFallback: false, + SingleConn: true, + DetectLocalDC: false, } } diff --git a/balancers/config.go b/balancers/config.go index 8bc38199c..a79c2cde1 100644 --- a/balancers/config.go +++ b/balancers/config.go @@ -112,6 +112,7 @@ func FromConfig(config string, opts ...fromConfigOption) *balancerConfig.Config var ( h = fromConfigOptionsHolder{ fallbackBalancer: Default(), + errorHandler: nil, } b *balancerConfig.Config err error diff --git a/config/defaults.go b/config/defaults.go index e63867808..c0a35523b 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -12,6 +12,7 @@ import ( "github.com/ydb-platform/ydb-go-sdk/v3/balancers" "github.com/ydb-platform/ydb-go-sdk/v3/credentials" + "github.com/ydb-platform/ydb-go-sdk/v3/internal/config" "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack" "github.com/ydb-platform/ydb-go-sdk/v3/internal/xresolver" "github.com/ydb-platform/ydb-go-sdk/v3/trace" @@ -78,10 +79,12 @@ func certPool() *x509.CertPool { } func defaultTLSConfig() *tls.Config { - return &tls.Config{ - MinVersion: tls.VersionTLS12, - RootCAs: certPool(), - } + config := new(tls.Config) + + config.MinVersion = tls.VersionTLS12 + config.RootCAs = certPool() + + return config } func defaultConfig() (c *Config) { @@ -89,9 +92,18 @@ func defaultConfig() (c *Config) { credentials: credentials.NewAnonymousCredentials( credentials.WithSourceInfo(stack.Record(0)), ), - balancerConfig: balancers.Default(), - tlsConfig: defaultTLSConfig(), - dialTimeout: DefaultDialTimeout, - trace: &trace.Driver{}, + balancerConfig: balancers.Default(), + tlsConfig: defaultTLSConfig(), + dialTimeout: DefaultDialTimeout, + trace: new(trace.Driver), + Common: config.Common{}, + connectionTTL: time.Duration(0), + secure: false, + endpoint: "", + database: "", + metaOptions: nil, + grpcOptions: nil, + meta: nil, + excludeGRPCCodesForPessimization: nil, } } diff --git a/driver.go b/driver.go index 7ef1e765d..291a450eb 100644 --- a/driver.go +++ b/driver.go @@ -108,7 +108,7 @@ func (d *Driver) trace() *trace.Driver { return d.config.Trace() } - return &trace.Driver{} + return new(trace.Driver) } // Close closes Driver and clear resources @@ -316,10 +316,9 @@ func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, e } }() - d := &Driver{ - children: make(map[uint64]*Driver), - ctxCancel: driverCtxCancel, - } + d := new(Driver) + d.children = make(map[uint64]*Driver) + d.ctxCancel = driverCtxCancel if caFile, has := os.LookupEnv("YDB_SSL_ROOT_CERTIFICATES_FILE"); has { d.opts = append(d.opts, diff --git a/examples/basic/gorm/data.go b/examples/basic/gorm/data.go index b5b72f269..905f45c73 100644 --- a/examples/basic/gorm/data.go +++ b/examples/basic/gorm/data.go @@ -4,361 +4,523 @@ import "time" var data = []Series{ { - Title: "IT Crowd", + ID: "", + Comment: "", + Title: "IT Crowd", Info: "" + "The IT Crowd is a British sitcom produced by Channel 4, written by Graham Linehan, produced by " + "Ash Atalla and starring Chris O'Dowd, Richard Ayoade, Katherine Parkinson, and Matt Berry.", ReleaseDate: date("2006-02-03"), Seasons: []Season{ { + ID: "", + SeriesID: "", Title: "Season 1", FirstAired: date("2006-02-03"), LastAired: date("2006-03-03"), Episodes: []Episode{ { - Title: "Yesterday's Jam", - AirDate: date("2006-02-03"), + ID: "", + SeasonID: "", + Title: "Yesterday's Jam", + AirDate: date("2006-02-03"), }, { - Title: "Calamity Jen", - AirDate: date("2006-02-03"), + ID: "", + SeasonID: "", + Title: "Calamity Jen", + AirDate: date("2006-02-03"), }, { - Title: "Fifty-Fifty", - AirDate: date("2006-02-10"), + ID: "", + SeasonID: "", + Title: "Fifty-Fifty", + AirDate: date("2006-02-10"), }, { - Title: "The Red Door", - AirDate: date("2006-02-17"), + ID: "", + SeasonID: "", + Title: "The Red Door", + AirDate: date("2006-02-17"), }, { - Title: "The Haunting of Bill Crouse", - AirDate: date("2006-02-24"), + ID: "", + SeasonID: "", + Title: "The Haunting of Bill Crouse", + AirDate: date("2006-02-24"), }, { - Title: "Aunt Irma Visits", - AirDate: date("2006-03-03"), + ID: "", + SeasonID: "", + Title: "Aunt Irma Visits", + AirDate: date("2006-03-03"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 2", FirstAired: date("2007-08-24"), LastAired: date("2007-09-28"), Episodes: []Episode{ { - Title: "The Work Outing", - AirDate: date("2006-08-24"), + ID: "", + SeasonID: "", + Title: "The Work Outing", + AirDate: date("2006-08-24"), }, { - Title: "Return of the Golden Child", - AirDate: date("2007-08-31"), + ID: "", + SeasonID: "", + Title: "Return of the Golden Child", + AirDate: date("2007-08-31"), }, { - Title: "Moss and the German", - AirDate: date("2007-09-07"), + ID: "", + SeasonID: "", + Title: "Moss and the German", + AirDate: date("2007-09-07"), }, { - Title: "The Dinner Party", - AirDate: date("2007-09-14"), + ID: "", + SeasonID: "", + Title: "The Dinner Party", + AirDate: date("2007-09-14"), }, { - Title: "Smoke and Mirrors", - AirDate: date("2007-09-21"), + ID: "", + SeasonID: "", + Title: "Smoke and Mirrors", + AirDate: date("2007-09-21"), }, { - Title: "Men Without Women", - AirDate: date("2007-09-28"), + ID: "", + SeasonID: "", + Title: "Men Without Women", + AirDate: date("2007-09-28"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 3", FirstAired: date("2008-11-21"), LastAired: date("2008-12-26"), Episodes: []Episode{ { - Title: "From Hell", - AirDate: date("2008-11-21"), + ID: "", + SeasonID: "", + Title: "From Hell", + AirDate: date("2008-11-21"), }, { - Title: "Are We Not Men?", - AirDate: date("2008-11-28"), + ID: "", + SeasonID: "", + Title: "Are We Not Men?", + AirDate: date("2008-11-28"), }, { - Title: "Tramps Like Us", - AirDate: date("2008-12-05"), + ID: "", + SeasonID: "", + Title: "Tramps Like Us", + AirDate: date("2008-12-05"), }, { - Title: "The Speech", - AirDate: date("2008-12-12"), + ID: "", + SeasonID: "", + Title: "The Speech", + AirDate: date("2008-12-12"), }, { - Title: "Friendface", - AirDate: date("2008-12-19"), + ID: "", + SeasonID: "", + Title: "Friendface", + AirDate: date("2008-12-19"), }, { - Title: "Calendar Geeks", - AirDate: date("2008-12-26"), + ID: "", + SeasonID: "", + Title: "Calendar Geeks", + AirDate: date("2008-12-26"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 4", FirstAired: date("2010-06-25"), LastAired: date("2010-07-30"), Episodes: []Episode{ { - Title: "Jen The Fredo", - AirDate: date("2010-06-25"), + ID: "", + SeasonID: "", + Title: "Jen The Fredo", + AirDate: date("2010-06-25"), }, { - Title: "The Final Countdown", - AirDate: date("2010-07-02"), + ID: "", + SeasonID: "", + Title: "The Final Countdown", + AirDate: date("2010-07-02"), }, { - Title: "Something Happened", - AirDate: date("2010-07-09"), + ID: "", + SeasonID: "", + Title: "Something Happened", + AirDate: date("2010-07-09"), }, { - Title: "Italian For Beginners", - AirDate: date("2010-07-16"), + ID: "", + SeasonID: "", + Title: "Italian For Beginners", + AirDate: date("2010-07-16"), }, { - Title: "Bad Boys", - AirDate: date("2010-07-23"), + ID: "", + SeasonID: "", + Title: "Bad Boys", + AirDate: date("2010-07-23"), }, { - Title: "Reynholm vs Reynholm", - AirDate: date("2010-07-30"), + ID: "", + SeasonID: "", + Title: "Reynholm vs Reynholm", + AirDate: date("2010-07-30"), }, }, }, }, }, { - Title: "Silicon Valley", + ID: "", + Comment: "", + Title: "Silicon Valley", Info: "" + "Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and " + "Dave Krinsky. The series focuses on five young men who founded a startup company in Silicon Valley.", ReleaseDate: date("2014-04-06"), Seasons: []Season{ { + ID: "", + SeriesID: "", Title: "Season 1", FirstAired: date("2006-02-03"), LastAired: date("2006-03-03"), Episodes: []Episode{ { - Title: "Minimum Viable Product", - AirDate: date("2014-04-06"), + ID: "", + SeasonID: "", + Title: "Minimum Viable Product", + AirDate: date("2014-04-06"), }, { - Title: "The Cap Table", - AirDate: date("2014-04-13"), + ID: "", + SeasonID: "", + Title: "The Cap Table", + AirDate: date("2014-04-13"), }, { - Title: "Articles of Incorporation", - AirDate: date("2014-04-20"), + ID: "", + SeasonID: "", + Title: "Articles of Incorporation", + AirDate: date("2014-04-20"), }, { - Title: "Fiduciary Duties", - AirDate: date("2014-04-27"), + ID: "", + SeasonID: "", + Title: "Fiduciary Duties", + AirDate: date("2014-04-27"), }, { - Title: "Signaling Risk", - AirDate: date("2014-05-04"), + ID: "", + SeasonID: "", + Title: "Signaling Risk", + AirDate: date("2014-05-04"), }, { - Title: "Third Party Insourcing", - AirDate: date("2014-05-11"), + ID: "", + SeasonID: "", + Title: "Third Party Insourcing", + AirDate: date("2014-05-11"), }, { - Title: "Proof of Concept", - AirDate: date("2014-05-18"), + ID: "", + SeasonID: "", + Title: "Proof of Concept", + AirDate: date("2014-05-18"), }, { - Title: "Optimal Tip-to-Tip Efficiency", - AirDate: date("2014-06-01"), + ID: "", + SeasonID: "", + Title: "Optimal Tip-to-Tip Efficiency", + AirDate: date("2014-06-01"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 2", FirstAired: date("2007-08-24"), LastAired: date("2007-09-28"), Episodes: []Episode{ { - Title: "Sand Hill Shuffle", - AirDate: date("2015-04-12"), + ID: "", + SeasonID: "", + Title: "Sand Hill Shuffle", + AirDate: date("2015-04-12"), }, { - Title: "Runaway Devaluation", - AirDate: date("2015-04-19"), + ID: "", + SeasonID: "", + Title: "Runaway Devaluation", + AirDate: date("2015-04-19"), }, { - Title: "Bad Money", - AirDate: date("2015-04-26"), + ID: "", + SeasonID: "", + Title: "Bad Money", + AirDate: date("2015-04-26"), }, { - Title: "The Lady", - AirDate: date("2015-05-03"), + ID: "", + SeasonID: "", + Title: "The Lady", + AirDate: date("2015-05-03"), }, { - Title: "Server Space", - AirDate: date("2015-05-10"), + ID: "", + SeasonID: "", + Title: "Server Space", + AirDate: date("2015-05-10"), }, { - Title: "Homicide", - AirDate: date("2015-05-17"), + ID: "", + SeasonID: "", + Title: "Homicide", + AirDate: date("2015-05-17"), }, { - Title: "Adult Content", - AirDate: date("2015-05-24"), + ID: "", + SeasonID: "", + Title: "Adult Content", + AirDate: date("2015-05-24"), }, { - Title: "White Hat/Black Hat", - AirDate: date("2015-05-31"), + ID: "", + SeasonID: "", + Title: "White Hat/Black Hat", + AirDate: date("2015-05-31"), }, { - Title: "Binding Arbitration", - AirDate: date("2015-06-07"), + ID: "", + SeasonID: "", + Title: "Binding Arbitration", + AirDate: date("2015-06-07"), }, { - Title: "Two Days of the Condor", - AirDate: date("2015-06-14"), + ID: "", + SeasonID: "", + Title: "Two Days of the Condor", + AirDate: date("2015-06-14"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 3", FirstAired: date("2008-11-21"), LastAired: date("2008-12-26"), Episodes: []Episode{ { - Title: "Founder Friendly", - AirDate: date("2016-04-24"), + ID: "", + SeasonID: "", + Title: "Founder Friendly", + AirDate: date("2016-04-24"), }, { - Title: "Two in the Box", - AirDate: date("2016-05-01"), + ID: "", + SeasonID: "", + Title: "Two in the Box", + AirDate: date("2016-05-01"), }, { - Title: "Meinertzhagen's Haversack", - AirDate: date("2016-05-08"), + ID: "", + SeasonID: "", + Title: "Meinertzhagen's Haversack", + AirDate: date("2016-05-08"), }, { - Title: "Maleant Data Systems Solutions", - AirDate: date("2016-05-15"), + ID: "", + SeasonID: "", + Title: "Maleant Data Systems Solutions", + AirDate: date("2016-05-15"), }, { - Title: "The Empty Chair", - AirDate: date("2016-05-22"), + ID: "", + SeasonID: "", + Title: "The Empty Chair", + AirDate: date("2016-05-22"), }, { - Title: "Bachmanity Insanity", - AirDate: date("2016-05-29"), + ID: "", + SeasonID: "", + Title: "Bachmanity Insanity", + AirDate: date("2016-05-29"), }, { - Title: "To Build a Better Beta", - AirDate: date("2016-06-05"), + ID: "", + SeasonID: "", + Title: "To Build a Better Beta", + AirDate: date("2016-06-05"), }, { - Title: "Bachman's Earnings Over-Ride", - AirDate: date("2016-06-12"), + ID: "", + SeasonID: "", + Title: "Bachman's Earnings Over-Ride", + AirDate: date("2016-06-12"), }, { - Title: "Daily Active Users", - AirDate: date("2016-06-19"), + ID: "", + SeasonID: "", + Title: "Daily Active Users", + AirDate: date("2016-06-19"), }, { - Title: "The Uptick", - AirDate: date("2016-06-26"), + ID: "", + SeasonID: "", + Title: "The Uptick", + AirDate: date("2016-06-26"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 4", FirstAired: date("2010-06-25"), LastAired: date("2010-07-30"), Episodes: []Episode{ { - Title: "Success Failure", - AirDate: date("2017-04-23"), + ID: "", + SeasonID: "", + Title: "Success Failure", + AirDate: date("2017-04-23"), }, { - Title: "Terms of Service", - AirDate: date("2017-04-30"), + ID: "", + SeasonID: "", + Title: "Terms of Service", + AirDate: date("2017-04-30"), }, { - Title: "Intellectual Property", - AirDate: date("2017-05-07"), + ID: "", + SeasonID: "", + Title: "Intellectual Property", + AirDate: date("2017-05-07"), }, { - Title: "Teambuilding Exercise", - AirDate: date("2017-05-14"), + ID: "", + SeasonID: "", + Title: "Teambuilding Exercise", + AirDate: date("2017-05-14"), }, { - Title: "The Blood Boy", - AirDate: date("2017-05-21"), + ID: "", + SeasonID: "", + Title: "The Blood Boy", + AirDate: date("2017-05-21"), }, { - Title: "Customer Service", - AirDate: date("2017-05-28"), + ID: "", + SeasonID: "", + Title: "Customer Service", + AirDate: date("2017-05-28"), }, { - Title: "The Patent Troll", - AirDate: date("2017-06-04"), + ID: "", + SeasonID: "", + Title: "The Patent Troll", + AirDate: date("2017-06-04"), }, { - Title: "The Keenan Vortex", - AirDate: date("2017-06-11"), + ID: "", + SeasonID: "", + Title: "The Keenan Vortex", + AirDate: date("2017-06-11"), }, { - Title: "Hooli-Con", - AirDate: date("2017-06-18"), + ID: "", + SeasonID: "", + Title: "Hooli-Con", + AirDate: date("2017-06-18"), }, { - Title: "Server Error", - AirDate: date("2017-06-25"), + ID: "", + SeasonID: "", + Title: "Server Error", + AirDate: date("2017-06-25"), }, }, }, { + ID: "", + SeriesID: "", Title: "Season 5", FirstAired: date("2018-03-25"), LastAired: date("2018-05-13"), Episodes: []Episode{ { - Title: "Grow Fast or Die Slow", - AirDate: date("2018-03-25"), + ID: "", + SeasonID: "", + Title: "Grow Fast or Die Slow", + AirDate: date("2018-03-25"), }, { - Title: "Reorientation", - AirDate: date("2018-04-01"), + ID: "", + SeasonID: "", + Title: "Reorientation", + AirDate: date("2018-04-01"), }, { - Title: "Chief Operating Officer", - AirDate: date("2018-04-08"), + ID: "", + SeasonID: "", + Title: "Chief Operating Officer", + AirDate: date("2018-04-08"), }, { - Title: "Tech Evangelist", - AirDate: date("2018-04-15"), + ID: "", + SeasonID: "", + Title: "Tech Evangelist", + AirDate: date("2018-04-15"), }, { - Title: "Facial Recognition", - AirDate: date("2018-04-22"), + ID: "", + SeasonID: "", + Title: "Facial Recognition", + AirDate: date("2018-04-22"), }, { - Title: "Artificial Emotional Intelligence", - AirDate: date("2018-04-29"), + ID: "", + SeasonID: "", + Title: "Artificial Emotional Intelligence", + AirDate: date("2018-04-29"), }, { - Title: "Initial Coin Offering", - AirDate: date("2018-05-06"), + ID: "", + SeasonID: "", + Title: "Initial Coin Offering", + AirDate: date("2018-05-06"), }, { - Title: "Fifty-One Percent", - AirDate: date("2018-05-13"), + ID: "", + SeasonID: "", + Title: "Fifty-One Percent", + AirDate: date("2018-05-13"), }, }, }, diff --git a/examples/basic/gorm/main.go b/examples/basic/gorm/main.go index 067832954..3baa8ff85 100644 --- a/examples/basic/gorm/main.go +++ b/examples/basic/gorm/main.go @@ -3,6 +3,7 @@ package main import ( "log" "os" + "time" ydb "github.com/ydb-platform/gorm-driver" environ "github.com/ydb-platform/ydb-go-sdk-auth-environ" @@ -21,9 +22,8 @@ SQLITE_CONNECTION_STRING YDB_CONNECTION_STRING` func main() { - cfg := &gorm.Config{ - Logger: logger.Default.LogMode(logger.Error), - } + cfg := new(gorm.Config) + cfg.Logger = logger.Default.LogMode(logger.Error) // connect var db *gorm.DB @@ -74,17 +74,17 @@ func main() { func prepareScheme(db *gorm.DB) error { if err := db.Migrator().DropTable( - &Series{}, - &Season{}, - &Episode{}, + &Series{ID: "", Title: "", Info: "", Comment: "", ReleaseDate: time.Time{}, Seasons: nil}, + &Season{ID: "", SeriesID: "", Title: "", FirstAired: time.Time{}, LastAired: time.Time{}, Episodes: nil}, + &Episode{ID: "", SeasonID: "", Title: "", AirDate: time.Time{}}, ); err != nil { return err } return db.AutoMigrate( - &Series{}, - &Season{}, - &Episode{}, + &Series{ID: "", Title: "", Info: "", Comment: "", ReleaseDate: time.Time{}, Seasons: nil}, + &Season{ID: "", SeriesID: "", Title: "", FirstAired: time.Time{}, LastAired: time.Time{}, Episodes: nil}, + &Episode{ID: "", SeasonID: "", Title: "", AirDate: time.Time{}}, ) } @@ -134,13 +134,23 @@ func findEpisodesByTitle(db *gorm.DB, fragment string) error { log.Println("all episodes with title with word 'bad':") for i := range episodes { ss := Season{ - ID: episodes[i].SeasonID, + ID: episodes[i].SeasonID, + SeriesID: "", + Title: "", + FirstAired: time.Time{}, + LastAired: time.Time{}, + Episodes: nil, } if err := db.Take(&ss).Error; err != nil { return err } s := Series{ - ID: ss.SeriesID, + ID: ss.SeriesID, + Title: "", + Info: "", + Comment: "", + ReleaseDate: time.Time{}, + Seasons: nil, } if err := db.Take(&s).Error; err != nil { return err diff --git a/examples/basic/xorm/data.go b/examples/basic/xorm/data.go index c6cfbb3fe..a343db4ee 100644 --- a/examples/basic/xorm/data.go +++ b/examples/basic/xorm/data.go @@ -32,6 +32,7 @@ func episodeData(seasonID, episodeID, title string, date time.Time) *Episodes { SeasonID: seasonID, Title: title, AirDate: date, + Views: 0, } } diff --git a/examples/basic/xorm/main.go b/examples/basic/xorm/main.go index 8a0961af5..fef70bf5b 100644 --- a/examples/basic/xorm/main.go +++ b/examples/basic/xorm/main.go @@ -70,12 +70,20 @@ func main() { } func prepareScheme(db *xorm.Engine) error { - err := db.DropTables(&Series{}, &Seasons{}, &Episodes{}) + err := db.DropTables( + &Series{ID: "", Title: "", Info: "", Comment: "", ReleaseDate: time.Time{}}, + &Seasons{ID: "", SeriesID: "", Title: "", FirstAired: time.Time{}, LastAired: time.Time{}}, + &Episodes{ID: "", SeasonID: "", Title: "", AirDate: time.Time{}, Views: 0}, + ) if err != nil { return err } - err = db.CreateTables(&Series{}, &Seasons{}, &Episodes{}) + err = db.CreateTables( + &Series{ID: "", Title: "", Info: "", Comment: "", ReleaseDate: time.Time{}}, + &Seasons{ID: "", SeriesID: "", Title: "", FirstAired: time.Time{}, LastAired: time.Time{}}, + &Episodes{ID: "", SeasonID: "", Title: "", AirDate: time.Time{}, Views: 0}, + ) return err } @@ -154,14 +162,22 @@ func findEpisodesByTitle(db *xorm.Engine, fragment string) error { log.Println("all episodes with title with word 'bad':") for _, e := range episodes { ss := Seasons{ - ID: e.SeasonID, + ID: e.SeasonID, + SeriesID: "", + Title: "", + FirstAired: time.Time{}, + LastAired: time.Time{}, } if _, err := session.Get(&ss); err != nil { return err } s := Series{ - ID: ss.SeriesID, + ID: ss.SeriesID, + Title: "", + Info: "", + Comment: "", + ReleaseDate: time.Time{}, } if _, err := session.Get(&s); err != nil { return err diff --git a/examples/read_table/orders.go b/examples/read_table/orders.go index c9e007193..a61205aa4 100644 --- a/examples/read_table/orders.go +++ b/examples/read_table/orders.go @@ -148,7 +148,7 @@ func readTable(ctx context.Context, c table.Client, path string, opts ...options defer func() { _ = res.Close() }() - r := row{} + r := row{id: 0, orderID: 0, date: time.Time{}, description: ""} for res.NextResultSet(ctx) { for res.NextRow() { if res.CurrentResultSet().ColumnCount() == 4 { diff --git a/examples/serverless/healthcheck/main.go b/examples/serverless/healthcheck/main.go index cf4d72277..5844c930e 100644 --- a/examples/serverless/healthcheck/main.go +++ b/examples/serverless/healthcheck/main.go @@ -16,7 +16,7 @@ var ( prefix string count int interval time.Duration - urls = URLs{} + urls = URLs{urls: nil} ) // URLs is a flag.Value implementation which holds URL's as string slice diff --git a/examples/serverless/healthcheck/service.go b/examples/serverless/healthcheck/service.go index 6391da68c..56729629a 100644 --- a/examples/serverless/healthcheck/service.go +++ b/examples/serverless/healthcheck/service.go @@ -29,14 +29,17 @@ var once sync.Once func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service, err error) { once.Do(func() { + transport := new(http.Transport) + transport.TLSClientConfig = new(tls.Config) + transport.TLSClientConfig.InsecureSkipVerify = true + s = &service{ + db: nil, client: &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, //nolint:gosec - }, - }, - Timeout: time.Second * 10, + Transport: transport, + CheckRedirect: nil, + Jar: nil, + Timeout: time.Second * 10, }, } s.db, err = ydb.Open(ctx, dsn, opts...) diff --git a/examples/serverless/url_shortener/main.go b/examples/serverless/url_shortener/main.go index 24bb259cc..443d4be4a 100644 --- a/examples/serverless/url_shortener/main.go +++ b/examples/serverless/url_shortener/main.go @@ -99,8 +99,20 @@ func main() { defer s.Close(ctx) server := &http.Server{ //nolint:gosec - Addr: ":" + strconv.Itoa(port), - Handler: s.router, + Addr: ":" + strconv.Itoa(port), + Handler: s.router, + DisableGeneralOptionsHandler: false, + TLSConfig: nil, + ReadTimeout: time.Duration(0), + ReadHeaderTimeout: time.Duration(0), + WriteTimeout: time.Duration(0), + IdleTimeout: time.Duration(0), + MaxHeaderBytes: 0, + TLSNextProto: nil, + ConnState: nil, + ErrorLog: nil, + BaseContext: nil, + ConnContext: nil, } defer func() { _ = server.Shutdown(ctx) diff --git a/examples/serverless/url_shortener/service.go b/examples/serverless/url_shortener/service.go index 37be7249b..f121daf34 100644 --- a/examples/serverless/url_shortener/service.go +++ b/examples/serverless/url_shortener/service.go @@ -88,9 +88,11 @@ func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service var ( registry = prometheus.NewRegistry() calls = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: "app", - Name: "calls", - Help: "application calls counter", + Namespace: "app", + Name: "calls", + Help: "application calls counter", + Subsystem: "", + ConstLabels: nil, }, []string{ "method", "success", @@ -110,14 +112,18 @@ func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service (5000 * time.Millisecond).Seconds(), (10000 * time.Millisecond).Seconds(), }, + Subsystem: "", + ConstLabels: nil, }, []string{ "success", "method", }) callsErrors = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: "app", - Name: "errors", - Help: "application errors counter", + Namespace: "app", + Name: "errors", + Help: "application errors counter", + Subsystem: "", + ConstLabels: nil, }, []string{ "method", }) @@ -139,6 +145,7 @@ func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service ) s = &service{ + db: nil, registry: registry, router: mux.NewRouter(), @@ -155,7 +162,15 @@ func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service } s.router.Handle("/metrics", promhttp.InstrumentMetricHandler( - registry, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}), + registry, promhttp.HandlerFor(registry, promhttp.HandlerOpts{ + ErrorLog: nil, + ErrorHandling: 0, + Registry: nil, + DisableCompression: false, + MaxRequestsInFlight: 0, + Timeout: time.Duration(0), + EnableOpenMetrics: false, + }), )) s.router.HandleFunc("/", s.handleIndex).Methods(http.MethodGet) s.router.HandleFunc("/shorten", s.handleShorten).Methods(http.MethodPost) diff --git a/examples/topic/cdc-cache-bus-freeseats/balancer.go b/examples/topic/cdc-cache-bus-freeseats/balancer.go index 6fba494e0..989d13819 100644 --- a/examples/topic/cdc-cache-bus-freeseats/balancer.go +++ b/examples/topic/cdc-cache-bus-freeseats/balancer.go @@ -13,6 +13,7 @@ type balancer struct { func newBalancer(handlers ...http.Handler) *balancer { return &balancer{ handlers: handlers, + counter: 0, } } diff --git a/examples/topic/cdc-cache-bus-freeseats/cache.go b/examples/topic/cdc-cache-bus-freeseats/cache.go index 4e67084f6..077e42ec7 100644 --- a/examples/topic/cdc-cache-bus-freeseats/cache.go +++ b/examples/topic/cdc-cache-bus-freeseats/cache.go @@ -15,8 +15,10 @@ type Cache struct { func NewCache(timeout time.Duration) *Cache { return &Cache{ - timeout: timeout, - values: make(map[string]CacheItem), + timeout: timeout, + values: make(map[string]CacheItem), + m: sync.Mutex{}, + setCounter: 0, } } diff --git a/examples/topic/cdc-cache-bus-freeseats/database.go b/examples/topic/cdc-cache-bus-freeseats/database.go index 43ad188ce..2b44a5b55 100644 --- a/examples/topic/cdc-cache-bus-freeseats/database.go +++ b/examples/topic/cdc-cache-bus-freeseats/database.go @@ -67,7 +67,11 @@ UPSERT INTO bus (id, freeSeats) VALUES ("bus1", 40), ("bus2", 60); func createCosumers(ctx context.Context, db *ydb.Driver, consumersCount int) error { for i := 0; i < consumersCount; i++ { err := db.Topic().Alter(ctx, "bus/updates", topicoptions.AlterWithAddConsumers(topictypes.Consumer{ - Name: consumerName(i), + Name: consumerName(i), + Important: false, + SupportedCodecs: nil, + ReadFrom: time.Time{}, + Attributes: nil, })) if err != nil { return err diff --git a/examples/topic/cdc-cache-bus-freeseats/webserver.go b/examples/topic/cdc-cache-bus-freeseats/webserver.go index 3825fabce..b10ffd42d 100644 --- a/examples/topic/cdc-cache-bus-freeseats/webserver.go +++ b/examples/topic/cdc-cache-bus-freeseats/webserver.go @@ -27,9 +27,11 @@ type server struct { func newServer(id int, db *ydb.Driver, cacheTimeout time.Duration, useCDC bool) *server { res := &server{ - cache: NewCache(cacheTimeout), - db: db, - id: id, + cache: NewCache(cacheTimeout), + db: db, + id: id, + mux: http.ServeMux{}, + dbCounter: 0, } res.mux.HandleFunc("/", res.IndexPageHandler) diff --git a/examples/topic/cdc-cache-bus-freeseats/webserver_cdc.go b/examples/topic/cdc-cache-bus-freeseats/webserver_cdc.go index 70f4a1f22..96bcebe06 100644 --- a/examples/topic/cdc-cache-bus-freeseats/webserver_cdc.go +++ b/examples/topic/cdc-cache-bus-freeseats/webserver_cdc.go @@ -14,8 +14,10 @@ func (s *server) cdcLoop() { consumer := consumerName(s.id) reader, err := s.db.Topic().StartReader(consumer, topicoptions.ReadSelectors{ { - Path: "bus/updates", - ReadFrom: time.Now(), + Path: "bus/updates", + ReadFrom: time.Now(), + Partitions: nil, + MaxTimeLag: time.Duration(0), }, }, ) diff --git a/examples/topic/cdc-fill-and-read/cdc-reader.go b/examples/topic/cdc-fill-and-read/cdc-reader.go index b3771009d..50bf3b4cb 100644 --- a/examples/topic/cdc-fill-and-read/cdc-reader.go +++ b/examples/topic/cdc-fill-and-read/cdc-reader.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "time" "github.com/ydb-platform/ydb-go-sdk/v3" "github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions" @@ -14,7 +15,10 @@ func cdcRead(ctx context.Context, db *ydb.Driver, consumerName, topicPath string // Connect to changefeed log.Println("Start cdc read") - reader, err := db.Topic().StartReader(consumerName, []topicoptions.ReadSelector{{Path: topicPath}}) + reader, err := db.Topic().StartReader( + consumerName, + []topicoptions.ReadSelector{{Path: topicPath, Partitions: nil, ReadFrom: time.Time{}, MaxTimeLag: time.Duration(0)}}, + ) if err != nil { log.Fatal("failed to start read feed", err) } diff --git a/examples/topic/cdc-fill-and-read/main.go b/examples/topic/cdc-fill-and-read/main.go index 15878cd51..dc3bafdf4 100644 --- a/examples/topic/cdc-fill-and-read/main.go +++ b/examples/topic/cdc-fill-and-read/main.go @@ -103,7 +103,11 @@ func prepareTableWithCDC(ctx context.Context, db *ydb.Driver, prefix, tableName, log.Println("Create consumer") err = db.Topic().Alter(ctx, topicPath, topicoptions.AlterWithAddConsumers(topictypes.Consumer{ - Name: consumerName, + Name: consumerName, + Important: false, + SupportedCodecs: nil, + ReadFrom: time.Time{}, + Attributes: nil, })) if err != nil { panic(fmt.Errorf("failed to create feed consumer: %w", err)) diff --git a/examples/topic/topicreader/topicreader_simple.go b/examples/topic/topicreader/topicreader_simple.go index 793485fbb..8f04ead7b 100644 --- a/examples/topic/topicreader/topicreader_simple.go +++ b/examples/topic/topicreader/topicreader_simple.go @@ -44,7 +44,7 @@ func UnmarshalMessageContentToJSONStruct(msg *topicreader.Message) { // UnmarshalMessageContentToProtobufStruct is example for effective way for unmarshal protobuf message content to value func UnmarshalMessageContentToProtobufStruct(msg *topicreader.Message) { - v := &firestore.BundledDocumentMetadata{} // protobuf type + v := new(firestore.BundledDocumentMetadata) // protobuf type _ = topicsugar.ProtoUnmarshal(msg, v) } diff --git a/examples/topic/topicreader/topicreader_trace.go b/examples/topic/topicreader/topicreader_trace.go index 0a332efa8..5055fe538 100644 --- a/examples/topic/topicreader/topicreader_trace.go +++ b/examples/topic/topicreader/topicreader_trace.go @@ -17,6 +17,27 @@ func CommitNotify(ctx context.Context, db *ydb.Driver) { // called when receive commit notify from server fmt.Println(info.Topic, info.PartitionID, info.CommittedOffset) }, + OnReaderStart: nil, + OnReaderReconnect: nil, + OnReaderReconnectRequest: nil, + OnReaderPartitionReadStartResponse: nil, + OnReaderPartitionReadStopResponse: nil, + OnReaderCommit: nil, + OnReaderSendCommitMessage: nil, + OnReaderClose: nil, + OnReaderInit: nil, + OnReaderError: nil, + OnReaderUpdateToken: nil, + OnReaderSentDataRequest: nil, + OnReaderReceiveDataResponse: nil, + OnReaderReadMessages: nil, + OnReaderUnknownGrpcMessage: nil, + OnWriterReconnect: nil, + OnWriterInitStream: nil, + OnWriterClose: nil, + OnWriterCompressMessages: nil, + OnWriterSendMessages: nil, + OnWriterReadUnknownGrpcMessage: nil, }, ), ) @@ -61,6 +82,26 @@ func ExplicitPartitionStartStopHandler(ctx context.Context, db *ydb.Driver) { return nil }, + OnReaderStart: nil, + OnReaderReconnect: nil, + OnReaderReconnectRequest: nil, + OnReaderCommit: nil, + OnReaderSendCommitMessage: nil, + OnReaderCommittedNotify: nil, + OnReaderClose: nil, + OnReaderInit: nil, + OnReaderError: nil, + OnReaderUpdateToken: nil, + OnReaderSentDataRequest: nil, + OnReaderReceiveDataResponse: nil, + OnReaderReadMessages: nil, + OnReaderUnknownGrpcMessage: nil, + OnWriterReconnect: nil, + OnWriterInitStream: nil, + OnWriterClose: nil, + OnWriterCompressMessages: nil, + OnWriterSendMessages: nil, + OnWriterReadUnknownGrpcMessage: nil, }, ), ) @@ -134,6 +175,26 @@ func PartitionStartStopHandlerAndOwnReadProgressStorage(ctx context.Context, db trace.Topic{ OnReaderPartitionReadStartResponse: onPartitionStart, OnReaderPartitionReadStopResponse: onPartitionStop, + OnReaderStart: nil, + OnReaderReconnect: nil, + OnReaderReconnectRequest: nil, + OnReaderCommit: nil, + OnReaderSendCommitMessage: nil, + OnReaderCommittedNotify: nil, + OnReaderClose: nil, + OnReaderInit: nil, + OnReaderError: nil, + OnReaderUpdateToken: nil, + OnReaderSentDataRequest: nil, + OnReaderReceiveDataResponse: nil, + OnReaderReadMessages: nil, + OnReaderUnknownGrpcMessage: nil, + OnWriterReconnect: nil, + OnWriterInitStream: nil, + OnWriterClose: nil, + OnWriterCompressMessages: nil, + OnWriterSendMessages: nil, + OnWriterReadUnknownGrpcMessage: nil, }, ), ) diff --git a/examples/topic/topicwriter/topicwriter.go b/examples/topic/topicwriter/topicwriter.go index 354d3f454..a8cee1bc9 100644 --- a/examples/topic/topicwriter/topicwriter.go +++ b/examples/topic/topicwriter/topicwriter.go @@ -3,6 +3,7 @@ package topicwriter import ( "bytes" "context" + "time" "github.com/ydb-platform/ydb-go-sdk/v3" "github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions" @@ -30,15 +31,15 @@ func ConnectSelectCodec(ctx context.Context, db *ydb.Driver) *topicwriter.Writer func SendMessagesOneByOne(ctx context.Context, w *topicwriter.Writer) { data := []byte{1, 2, 3} - mess := topicwriter.Message{Data: bytes.NewReader(data)} + mess := topicwriter.Message{Data: bytes.NewReader(data), SeqNo: 0, CreatedAt: time.Time{}, Metadata: nil} _ = w.Write(ctx, mess) } func SendGroupOfMessages(ctx context.Context, w *topicwriter.Writer) { data1 := []byte{1, 2, 3} data2 := []byte{4, 5, 6} - mess1 := topicwriter.Message{Data: bytes.NewReader(data1)} - mess2 := topicwriter.Message{Data: bytes.NewReader(data2)} + mess1 := topicwriter.Message{Data: bytes.NewReader(data1), SeqNo: 0, CreatedAt: time.Time{}, Metadata: nil} + mess2 := topicwriter.Message{Data: bytes.NewReader(data2), SeqNo: 0, CreatedAt: time.Time{}, Metadata: nil} _ = w.Write(ctx, mess1, mess2) } diff --git a/internal/allocator/allocator.go b/internal/allocator/allocator.go index efb5fb3da..f39917b67 100644 --- a/internal/allocator/allocator.go +++ b/internal/allocator/allocator.go @@ -137,7 +137,7 @@ func (a *boolAllocator) Bool() (v *Ydb.Value_BoolValue) { func (a *boolAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_BoolValue{} + *v = Ydb.Value_BoolValue{BoolValue: false} boolPool.Put(v) } a.allocations = a.allocations[:0] @@ -156,7 +156,7 @@ func (a *bytesAllocator) Bytes() (v *Ydb.Value_BytesValue) { func (a *bytesAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_BytesValue{} + *v = Ydb.Value_BytesValue{BytesValue: []byte{}} bytesPool.Put(v) } a.allocations = a.allocations[:0] @@ -213,7 +213,7 @@ func (a *doubleAllocator) Double() (v *Ydb.Value_DoubleValue) { func (a *doubleAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_DoubleValue{} + *v = Ydb.Value_DoubleValue{DoubleValue: 0} doublePool.Put(v) } a.allocations = a.allocations[:0] @@ -232,7 +232,7 @@ func (a *floatAllocator) Float() (v *Ydb.Value_FloatValue) { func (a *floatAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_FloatValue{} + *v = Ydb.Value_FloatValue{FloatValue: 0} floatPool.Put(v) } a.allocations = a.allocations[:0] @@ -251,7 +251,7 @@ func (a *int32Allocator) Int32() (v *Ydb.Value_Int32Value) { func (a *int32Allocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_Int32Value{} + *v = Ydb.Value_Int32Value{Int32Value: 0} int32Pool.Put(v) } a.allocations = a.allocations[:0] @@ -270,7 +270,7 @@ func (a *int64Allocator) Int64() (v *Ydb.Value_Int64Value) { func (a *int64Allocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_Int64Value{} + *v = Ydb.Value_Int64Value{Int64Value: 0} int64Pool.Put(v) } a.allocations = a.allocations[:0] @@ -308,7 +308,7 @@ func (a *low128Allocator) Low128() (v *Ydb.Value_Low_128) { func (a *low128Allocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_Low_128{} + *v = Ydb.Value_Low_128{Low_128: 0} low128Pool.Put(v) } a.allocations = a.allocations[:0] @@ -327,7 +327,7 @@ func (a *nestedAllocator) Nested() (v *Ydb.Value_NestedValue) { func (a *nestedAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_NestedValue{} + *v = Ydb.Value_NestedValue{NestedValue: new(Ydb.Value)} nestedPool.Put(v) } a.allocations = a.allocations[:0] @@ -346,7 +346,7 @@ func (a *nullFlagAllocator) NullFlag() (v *Ydb.Value_NullFlagValue) { func (a *nullFlagAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_NullFlagValue{} + *v = Ydb.Value_NullFlagValue{NullFlagValue: 0} nullFlagPool.Put(v) } a.allocations = a.allocations[:0] @@ -384,7 +384,10 @@ func (a *pairAllocator) Pair() (v *Ydb.ValuePair) { func (a *pairAllocator) free() { for _, v := range a.allocations { - *v = Ydb.ValuePair{} + *v = Ydb.ValuePair{ + Key: new(Ydb.Value), + Payload: new(Ydb.Value), + } pairPool.Put(v) } a.allocations = a.allocations[:0] @@ -449,7 +452,7 @@ func (a *textAllocator) Text() (v *Ydb.Value_TextValue) { func (a *textAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_TextValue{} + *v = Ydb.Value_TextValue{TextValue: ""} textPool.Put(v) } a.allocations = a.allocations[:0] @@ -492,7 +495,7 @@ func (a *typeDecimalAllocator) TypeDecimal() (v *Ydb.Type_DecimalType) { func (a *typeDecimalAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_DecimalType{} + *v = Ydb.Type_DecimalType{DecimalType: new(Ydb.DecimalType)} typeDecimalPool.Put(v) } a.allocations = a.allocations[:0] @@ -511,7 +514,7 @@ func (a *typeDictAllocator) TypeDict() (v *Ydb.Type_DictType) { func (a *typeDictAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_DictType{} + *v = Ydb.Type_DictType{DictType: new(Ydb.DictType)} typeDictPool.Put(v) } a.allocations = a.allocations[:0] @@ -530,7 +533,7 @@ func (a *typeEmptyListAllocator) TypeEmptyList() (v *Ydb.Type_EmptyListType) { func (a *typeEmptyListAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_EmptyListType{} + *v = Ydb.Type_EmptyListType{EmptyListType: 0} typeEmptyListPool.Put(v) } a.allocations = a.allocations[:0] @@ -549,7 +552,7 @@ func (a *typeEmptyDictAllocator) TypeEmptyDict() (v *Ydb.Type_EmptyDictType) { func (a *typeEmptyDictAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_EmptyDictType{} + *v = Ydb.Type_EmptyDictType{EmptyDictType: 0} typeEmptyDictPool.Put(v) } a.allocations = a.allocations[:0] @@ -587,7 +590,7 @@ func (a *typeListAllocator) TypeList() (v *Ydb.Type_ListType) { func (a *typeListAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_ListType{} + *v = Ydb.Type_ListType{ListType: new(Ydb.ListType)} typeListPool.Put(v) } a.allocations = a.allocations[:0] @@ -606,7 +609,7 @@ func (a *typeOptionalAllocator) TypeOptional() (v *Ydb.Type_OptionalType) { func (a *typeOptionalAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_OptionalType{} + *v = Ydb.Type_OptionalType{OptionalType: new(Ydb.OptionalType)} typeOptionalPool.Put(v) } a.allocations = a.allocations[:0] @@ -625,7 +628,7 @@ func (a *typeStructAllocator) TypeStruct() (v *Ydb.Type_StructType) { func (a *typeStructAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_StructType{} + *v = Ydb.Type_StructType{StructType: new(Ydb.StructType)} typeStructPool.Put(v) } a.allocations = a.allocations[:0] @@ -644,7 +647,7 @@ func (a *typeTupleAllocator) TypeTuple() (v *Ydb.Type_TupleType) { func (a *typeTupleAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_TupleType{} + *v = Ydb.Type_TupleType{TupleType: new(Ydb.TupleType)} typeTuplePool.Put(v) } a.allocations = a.allocations[:0] @@ -663,7 +666,7 @@ func (a *typeVariantAllocator) TypeVariant() (v *Ydb.Type_VariantType) { func (a *typeVariantAllocator) free() { for _, v := range a.allocations { - *v = Ydb.Type_VariantType{} + *v = Ydb.Type_VariantType{VariantType: new(Ydb.VariantType)} typeVariantPool.Put(v) } a.allocations = a.allocations[:0] @@ -701,7 +704,7 @@ func (a *uint32Allocator) Uint32() (v *Ydb.Value_Uint32Value) { func (a *uint32Allocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_Uint32Value{} + *v = Ydb.Value_Uint32Value{Uint32Value: 0} uint32Pool.Put(v) } a.allocations = a.allocations[:0] @@ -720,7 +723,7 @@ func (a *uint64Allocator) Uint64() (v *Ydb.Value_Uint64Value) { func (a *uint64Allocator) free() { for _, v := range a.allocations { - *v = Ydb.Value_Uint64Value{} + *v = Ydb.Value_Uint64Value{Uint64Value: 0} uint64Pool.Put(v) } a.allocations = a.allocations[:0] diff --git a/internal/background/worker.go b/internal/background/worker.go index 55d5b0363..12a7eca04 100644 --- a/internal/background/worker.go +++ b/internal/background/worker.go @@ -36,7 +36,16 @@ type CallbackFunc func(ctx context.Context) func NewWorker(parent context.Context, name string) *Worker { w := Worker{ - name: name, + ctx: nil, + name: name, + workers: sync.WaitGroup{}, + closeReason: nil, + tasksCompleted: nil, + tasks: nil, + stop: nil, + onceInit: sync.Once{}, + m: xsync.Mutex{Mutex: sync.Mutex{}}, + closed: false, } w.ctx, w.stop = xcontext.WithCancel(parent) diff --git a/internal/backoff/backoff.go b/internal/backoff/backoff.go index d4b9cceeb..ac6ac9d32 100644 --- a/internal/backoff/backoff.go +++ b/internal/backoff/backoff.go @@ -84,7 +84,10 @@ func WithSeed(seed int64) option { func New(opts ...option) logBackoff { b := logBackoff{ - r: xrand.New(xrand.WithLock()), + slotDuration: time.Duration(0), + ceiling: 0, + jitterLimit: 0, + r: xrand.New(xrand.WithLock()), } for _, opt := range opts { if opt != nil { diff --git a/internal/backoff/backoff_test.go b/internal/backoff/backoff_test.go index 45cd7fd1e..85af1a0a9 100644 --- a/internal/backoff/backoff_test.go +++ b/internal/backoff/backoff_test.go @@ -60,13 +60,13 @@ func TestLogBackoff(t *testing.T) { WithSeed(0), ), exp: []exp{ - {gte: 0, lte: time.Second}, - {gte: 0, lte: 2 * time.Second}, - {gte: 0, lte: 4 * time.Second}, - {gte: 0, lte: 8 * time.Second}, - {gte: 0, lte: 8 * time.Second}, - {gte: 0, lte: 8 * time.Second}, - {gte: 0, lte: 8 * time.Second}, + {eq: 0, gte: 0, lte: time.Second}, + {eq: 0, gte: 0, lte: 2 * time.Second}, + {eq: 0, gte: 0, lte: 4 * time.Second}, + {eq: 0, gte: 0, lte: 8 * time.Second}, + {eq: 0, gte: 0, lte: 8 * time.Second}, + {eq: 0, gte: 0, lte: 8 * time.Second}, + {eq: 0, gte: 0, lte: 8 * time.Second}, }, seeds: 1000, }, @@ -78,13 +78,13 @@ func TestLogBackoff(t *testing.T) { WithSeed(0), ), exp: []exp{ - {gte: 500 * time.Millisecond, lte: time.Second}, - {gte: 1 * time.Second, lte: 2 * time.Second}, - {gte: 2 * time.Second, lte: 4 * time.Second}, - {gte: 4 * time.Second, lte: 8 * time.Second}, - {gte: 4 * time.Second, lte: 8 * time.Second}, - {gte: 4 * time.Second, lte: 8 * time.Second}, - {gte: 4 * time.Second, lte: 8 * time.Second}, + {eq: 0, gte: 500 * time.Millisecond, lte: time.Second}, + {eq: 0, gte: 1 * time.Second, lte: 2 * time.Second}, + {eq: 0, gte: 2 * time.Second, lte: 4 * time.Second}, + {eq: 0, gte: 4 * time.Second, lte: 8 * time.Second}, + {eq: 0, gte: 4 * time.Second, lte: 8 * time.Second}, + {eq: 0, gte: 4 * time.Second, lte: 8 * time.Second}, + {eq: 0, gte: 4 * time.Second, lte: 8 * time.Second}, }, seeds: 1000, }, @@ -96,14 +96,15 @@ func TestLogBackoff(t *testing.T) { WithSeed(0), ), exp: []exp{ - {eq: time.Second}, - {eq: 2 * time.Second}, - {eq: 4 * time.Second}, - {eq: 8 * time.Second}, - {eq: 8 * time.Second}, - {eq: 8 * time.Second}, - {eq: 8 * time.Second}, + {eq: time.Second, gte: 0, lte: 0}, + {eq: 2 * time.Second, gte: 0, lte: 0}, + {eq: 4 * time.Second, gte: 0, lte: 0}, + {eq: 8 * time.Second, gte: 0, lte: 0}, + {eq: 8 * time.Second, gte: 0, lte: 0}, + {eq: 8 * time.Second, gte: 0, lte: 0}, + {eq: 8 * time.Second, gte: 0, lte: 0}, }, + seeds: 0, }, { backoff: New( @@ -113,19 +114,20 @@ func TestLogBackoff(t *testing.T) { WithSeed(0), ), exp: []exp{ - {eq: time.Second}, - {eq: 2 * time.Second}, - {eq: 4 * time.Second}, - {eq: 8 * time.Second}, - {eq: 16 * time.Second}, - {eq: 32 * time.Second}, - {eq: 64 * time.Second}, - {eq: 64 * time.Second}, - {eq: 64 * time.Second}, - {eq: 64 * time.Second}, - {eq: 64 * time.Second}, - {eq: 64 * time.Second}, + {eq: time.Second, gte: 0, lte: 0}, + {eq: 2 * time.Second, gte: 0, lte: 0}, + {eq: 4 * time.Second, gte: 0, lte: 0}, + {eq: 8 * time.Second, gte: 0, lte: 0}, + {eq: 16 * time.Second, gte: 0, lte: 0}, + {eq: 32 * time.Second, gte: 0, lte: 0}, + {eq: 64 * time.Second, gte: 0, lte: 0}, + {eq: 64 * time.Second, gte: 0, lte: 0}, + {eq: 64 * time.Second, gte: 0, lte: 0}, + {eq: 64 * time.Second, gte: 0, lte: 0}, + {eq: 64 * time.Second, gte: 0, lte: 0}, + {eq: 64 * time.Second, gte: 0, lte: 0}, }, + seeds: 0, }, } { t.Run("", func(t *testing.T) { diff --git a/internal/balancer/balancer.go b/internal/balancer/balancer.go index b33f7266a..77189cd1c 100644 --- a/internal/balancer/balancer.go +++ b/internal/balancer/balancer.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "sort" + "sync" "google.golang.org/grpc" @@ -259,6 +260,17 @@ func New( driverConfig: driverConfig, pool: pool, localDCDetector: detectLocalDC, + config: balancerConfig.Config{ + Filter: nil, + AllowFallback: false, + SingleConn: false, + DetectLocalDC: false, + }, + discoveryClient: nil, + discoveryRepeater: nil, + mu: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + connectionsState: nil, + onApplyDiscoveredEndpoints: nil, } d := internalDiscovery.New(ctx, pool.Get( endpoint.New(driverConfig.Endpoint()), @@ -267,7 +279,12 @@ func New( b.discoveryClient = d if config := driverConfig.Balancer(); config == nil { - b.config = balancerConfig.Config{} + b.config = balancerConfig.Config{ + Filter: nil, + AllowFallback: false, + SingleConn: false, + DetectLocalDC: false, + } } else { b.config = *config } diff --git a/internal/balancer/connections_state.go b/internal/balancer/connections_state.go index e9196ead7..9a1ea8abc 100644 --- a/internal/balancer/connections_state.go +++ b/internal/balancer/connections_state.go @@ -27,6 +27,9 @@ func newConnectionsState( res := &connectionsState{ connByNodeID: connsToNodeIDMap(conns), rand: xrand.New(xrand.WithLock()), + prefer: nil, + fallback: nil, + all: nil, } res.prefer, res.fallback = sortPreferConnections(conns, filter, info, allowFallback) diff --git a/internal/bind/numeric_args.go b/internal/bind/numeric_args.go index 75319449a..7ff244ba3 100644 --- a/internal/bind/numeric_args.go +++ b/internal/bind/numeric_args.go @@ -20,8 +20,12 @@ func (m NumericArgs) blockID() blockID { func (m NumericArgs) RewriteQuery(sql string, args ...interface{}) (yql string, newArgs []interface{}, err error) { l := &sqlLexer{ src: sql, + start: 0, + pos: 0, + nested: 0, stateFn: numericArgsStateFn, rawStateFn: numericArgsStateFn, + parts: []interface{}{}, } for l.stateFn != nil { diff --git a/internal/bind/numeric_args_test.go b/internal/bind/numeric_args_test.go index 4f40da6c0..f5ad8ac13 100644 --- a/internal/bind/numeric_args_test.go +++ b/internal/bind/numeric_args_test.go @@ -27,7 +27,9 @@ func TestNumericArgsBindRewriteQuery(t *testing.T) { args: []interface{}{ 100, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: `SELECT $123abc, $1`, @@ -39,6 +41,7 @@ SELECT $123abc, $p0`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(200)), }, + err: nil, }, { sql: `SELECT $1, $2`, @@ -52,6 +55,7 @@ SELECT $name1, $name2`, table.ValueParam("$name1", types.Int32Value(100)), table.ValueParam("$name2", types.Int32Value(200)), }, + err: nil, }, { sql: `SELECT $1, $2`, @@ -65,6 +69,7 @@ SELECT $namedArg, $p1`, table.ValueParam("$namedArg", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: `SELECT $0, $1`, @@ -72,7 +77,9 @@ SELECT $namedArg, $p1`, 100, 200, }, - err: ErrUnexpectedNumericArgZero, + yql: "", + params: []interface{}{}, + err: ErrUnexpectedNumericArgZero, }, { sql: `SELECT $1, $2`, @@ -86,13 +93,16 @@ SELECT $p0, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: `SELECT $1, $2`, args: []interface{}{ 100, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: `SELECT $1, "$2"`, @@ -104,6 +114,7 @@ SELECT $p0, "$2"`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(100)), }, + err: nil, }, { sql: `SELECT $1, '$2'`, @@ -115,6 +126,7 @@ SELECT $p0, '$2'`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(100)), }, + err: nil, }, { sql: "SELECT $1, `$2`", @@ -125,9 +137,12 @@ SELECT $p0, '$2'`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(100)), }, + err: nil, }, { sql: "SELECT ?, $1, $p0", + args: []interface{}{}, + yql: "", params: []interface{}{}, err: ErrInconsistentArgs, }, @@ -153,6 +168,7 @@ SELECT $p0, $p1, $p2`, types.TextValue("test3"), )), }, + err: nil, }, { sql: "SELECT $1, $2, $3, $1, $2", @@ -176,6 +192,7 @@ SELECT $p0, $p1, $p2, $p0, $p1`, types.TextValue("test3"), )), }, + err: nil, }, { sql: "SELECT $1, $2, $3", @@ -199,6 +216,7 @@ SELECT $p0, $p1, $p2`, types.TextValue("test3"), )), }, + err: nil, }, { sql: "SELECT $1, a, b, c WHERE id = $1 AND date < $2 AND value IN ($3)", @@ -212,23 +230,30 @@ SELECT $p0, a, b, c WHERE id = $p0 AND date < $p1 AND value IN ($p2)`, table.ValueParam("$p1", types.TimestampValueFromTime(now)), table.ValueParam("$p2", types.ListValue(types.TextValue("3"))), }, + err: nil, }, { - sql: "SELECT 1", - yql: "SELECT 1", + sql: "SELECT 1", + args: []interface{}{}, + yql: "SELECT 1", + params: []interface{}{}, + err: nil, }, { - sql: ` -SELECT 1`, - yql: ` -SELECT 1`, + sql: `SELECT 1`, + args: []interface{}{}, + yql: `SELECT 1`, + params: []interface{}{}, + err: nil, }, { sql: "SELECT $1, $2", args: []interface{}{ 1, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: "SELECT $1, $2 -- some comment with $3", @@ -242,6 +267,7 @@ SELECT $p0, $p1 -- some comment with $3`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT $1 /* some comment with $3 */, $2", @@ -255,13 +281,16 @@ SELECT $p0 /* some comment with $3 */, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT $1, $2 -- some comment with $3", args: []interface{}{ 100, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: "SELECT $1, $2, $3", @@ -269,7 +298,9 @@ SELECT $p0 /* some comment with $3 */, $p1`, 100, 200, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: ` @@ -285,6 +316,7 @@ SELECT $p0 /* some comment with $3 */, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT $1, $2", @@ -298,6 +330,7 @@ SELECT $p0, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT $1, $2", @@ -311,6 +344,7 @@ SELECT $p0, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, } { t.Run("", func(t *testing.T) { diff --git a/internal/bind/params_test.go b/internal/bind/params_test.go index d715c07a1..a636bd6da 100644 --- a/internal/bind/params_test.go +++ b/internal/bind/params_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ydb-platform/ydb-go-sdk/v3/internal/params" - "github.com/ydb-platform/ydb-go-sdk/v3/table" "github.com/ydb-platform/ydb-go-sdk/v3/table/types" ) @@ -339,8 +338,9 @@ func TestToValue(t *testing.T) { func named(name string, value interface{}) driver.NamedValue { return driver.NamedValue{ - Name: name, - Value: value, + Name: name, + Ordinal: 0, + Value: value, } } @@ -371,7 +371,7 @@ func TestYdbParam(t *testing.T) { err: nil, }, { - src: driver.NamedValue{Value: uint(42)}, + src: driver.NamedValue{Name: "", Ordinal: 0, Value: uint(42)}, dst: nil, err: errUnnamedParam, }, @@ -411,18 +411,19 @@ func TestArgsToParams(t *testing.T) { }, { args: []interface{}{ - table.NewQueryParameters( + ¶ms.Parameters{ params.Named("$p0", types.Int32Value(1)), params.Named("$p1", types.Uint64Value(2)), params.Named("$p2", types.TextValue("3")), - ), - table.NewQueryParameters( + }, + ¶ms.Parameters{ params.Named("$p0", types.Int32Value(1)), params.Named("$p1", types.Uint64Value(2)), params.Named("$p2", types.TextValue("3")), - ), + }, }, - err: errMultipleQueryParameters, + params: []*params.Parameter{}, + err: errMultipleQueryParameters, }, { args: []interface{}{ @@ -452,9 +453,9 @@ func TestArgsToParams(t *testing.T) { }, { args: []interface{}{ - driver.NamedValue{Name: "$p0", Value: types.Int32Value(1)}, - driver.NamedValue{Name: "$p1", Value: types.Uint64Value(2)}, - driver.NamedValue{Name: "$p2", Value: types.TextValue("3")}, + driver.NamedValue{Name: "$p0", Ordinal: 0, Value: types.Int32Value(1)}, + driver.NamedValue{Name: "$p1", Ordinal: 0, Value: types.Uint64Value(2)}, + driver.NamedValue{Name: "$p2", Ordinal: 0, Value: types.TextValue("3")}, }, params: []*params.Parameter{ params.Named("$p0", types.Int32Value(1)), @@ -465,9 +466,9 @@ func TestArgsToParams(t *testing.T) { }, { args: []interface{}{ - driver.NamedValue{Value: params.Named("$p0", types.Int32Value(1))}, - driver.NamedValue{Value: params.Named("$p1", types.Uint64Value(2))}, - driver.NamedValue{Value: params.Named("$p2", types.TextValue("3"))}, + driver.NamedValue{Name: "$p0", Ordinal: 0, Value: params.Named("$p0", types.Int32Value(1))}, + driver.NamedValue{Name: "$p1", Ordinal: 0, Value: params.Named("$p1", types.Uint64Value(2))}, + driver.NamedValue{Name: "$p2", Ordinal: 0, Value: params.Named("$p2", types.TextValue("3"))}, }, params: []*params.Parameter{ params.Named("$p0", types.Int32Value(1)), @@ -478,9 +479,9 @@ func TestArgsToParams(t *testing.T) { }, { args: []interface{}{ - driver.NamedValue{Value: 1}, - driver.NamedValue{Value: uint64(2)}, - driver.NamedValue{Value: "3"}, + driver.NamedValue{Name: "$p0", Ordinal: 0, Value: 1}, + driver.NamedValue{Name: "$p1", Ordinal: 0, Value: uint64(2)}, + driver.NamedValue{Name: "$p2", Ordinal: 0, Value: "3"}, }, params: []*params.Parameter{ params.Named("$p0", types.Int32Value(1)), @@ -491,11 +492,11 @@ func TestArgsToParams(t *testing.T) { }, { args: []interface{}{ - driver.NamedValue{Value: table.NewQueryParameters( + driver.NamedValue{Name: "", Ordinal: 0, Value: ¶ms.Parameters{ params.Named("$p0", types.Int32Value(1)), params.Named("$p1", types.Uint64Value(2)), params.Named("$p2", types.TextValue("3")), - )}, + }}, }, params: []*params.Parameter{ params.Named("$p0", types.Int32Value(1)), @@ -506,15 +507,16 @@ func TestArgsToParams(t *testing.T) { }, { args: []interface{}{ - driver.NamedValue{Value: table.NewQueryParameters( + driver.NamedValue{Name: "", Ordinal: 0, Value: ¶ms.Parameters{ params.Named("$p0", types.Int32Value(1)), params.Named("$p1", types.Uint64Value(2)), params.Named("$p2", types.TextValue("3")), - )}, - driver.NamedValue{Value: params.Named("$p1", types.Uint64Value(2))}, - driver.NamedValue{Value: params.Named("$p2", types.TextValue("3"))}, + }}, + driver.NamedValue{Name: "$p1", Ordinal: 0, Value: params.Named("$p1", types.Uint64Value(2))}, + driver.NamedValue{Name: "$p2", Ordinal: 0, Value: params.Named("$p2", types.TextValue("3"))}, }, - err: errMultipleQueryParameters, + params: []*params.Parameter{}, + err: errMultipleQueryParameters, }, } { t.Run("", func(t *testing.T) { diff --git a/internal/bind/positional_args.go b/internal/bind/positional_args.go index e3c0afa13..1df73d5f0 100644 --- a/internal/bind/positional_args.go +++ b/internal/bind/positional_args.go @@ -21,8 +21,12 @@ func (m PositionalArgs) RewriteQuery(sql string, args ...interface{}) ( ) { l := &sqlLexer{ src: sql, + start: 0, + pos: 0, + nested: 0, stateFn: positionalArgsStateFn, rawStateFn: positionalArgsStateFn, + parts: []interface{}{}, } for l.stateFn != nil { diff --git a/internal/bind/positional_args_test.go b/internal/bind/positional_args_test.go index f1224730e..dce0cff32 100644 --- a/internal/bind/positional_args_test.go +++ b/internal/bind/positional_args_test.go @@ -34,13 +34,16 @@ SELECT $p0, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: `SELECT ?, ?`, args: []interface{}{ 100, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: `SELECT ?, "?"`, @@ -52,6 +55,7 @@ SELECT $p0, "?"`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(100)), }, + err: nil, }, { sql: `SELECT ?, '?'`, @@ -63,6 +67,7 @@ SELECT $p0, '?'`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(100)), }, + err: nil, }, { sql: "SELECT ?, `?`", @@ -73,10 +78,14 @@ SELECT $p0, '?'`, params: []interface{}{ table.ValueParam("$p0", types.Int32Value(100)), }, + err: nil, }, { - sql: "SELECT ?, $1, $p0", - err: ErrInconsistentArgs, + sql: "SELECT ?, $1, $p0", + args: []interface{}{}, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: "SELECT ?, ?, ?", @@ -100,6 +109,7 @@ SELECT $p0, $p1, $p2`, types.TextValue("test3"), )), }, + err: nil, }, { sql: "SELECT ?, ?, ?", @@ -123,6 +133,7 @@ SELECT $p0, $p1, $p2`, types.TextValue("test3"), )), }, + err: nil, }, { sql: "SELECT a, b, c WHERE id = ? AND date < ? AND value IN (?)", @@ -136,23 +147,30 @@ SELECT a, b, c WHERE id = $p0 AND date < $p1 AND value IN ($p2)`, table.ValueParam("$p1", types.TimestampValueFromTime(now)), table.ValueParam("$p2", types.ListValue(types.TextValue("3"))), }, + err: nil, }, { - sql: "SELECT 1", - yql: "SELECT 1", + sql: "SELECT 1", + args: []interface{}{}, + yql: "SELECT 1", + params: []interface{}{}, + err: nil, }, { - sql: ` -SELECT 1`, - yql: ` -SELECT 1`, + sql: `SELECT 1`, + args: []interface{}{}, + yql: `SELECT 1`, + params: []interface{}{}, + err: nil, }, { sql: "SELECT ?, ?", args: []interface{}{ 1, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: "SELECT ?, ? -- some comment with ?", @@ -166,6 +184,7 @@ SELECT $p0, $p1 -- some comment with ?`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT ? /* some comment with ? */, ?", @@ -179,13 +198,16 @@ SELECT $p0 /* some comment with ? */, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT ?, ? -- some comment with ?", args: []interface{}{ 100, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: "SELECT ?, ?, ?", @@ -193,7 +215,9 @@ SELECT $p0 /* some comment with ? */, $p1`, 100, 200, }, - err: ErrInconsistentArgs, + yql: "", + params: []interface{}{}, + err: ErrInconsistentArgs, }, { sql: ` @@ -209,6 +233,7 @@ SELECT $p0 /* some comment with ? */, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT ?, ?", @@ -222,6 +247,7 @@ SELECT $p0, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, { sql: "SELECT ?, ?", @@ -235,6 +261,7 @@ SELECT $p0, $p1`, table.ValueParam("$p0", types.Int32Value(100)), table.ValueParam("$p1", types.Int32Value(200)), }, + err: nil, }, } { t.Run("", func(t *testing.T) { diff --git a/internal/certificates/certificates.go b/internal/certificates/certificates.go index 8282dce79..be18ebc63 100644 --- a/internal/certificates/certificates.go +++ b/internal/certificates/certificates.go @@ -53,7 +53,11 @@ func loadFromFileCache(key string) (_ []*x509.Certificate, exists bool) { // FromFile reads and parses pem-encoded certificate(s) from file. func FromFile(file string, opts ...FromFileOption) ([]*x509.Certificate, error) { - options := fromFileOptions{} + options := fromFileOptions{ + onHit: nil, + onMiss: nil, + noCache: false, + } for _, opt := range opts { if opt != nil { opt(&options) @@ -108,7 +112,11 @@ func loadFromPemCache(key string) (_ *x509.Certificate, exists bool) { // parseCertificate is a cached version of x509.ParseCertificate. Cache key is string(der) func parseCertificate(der []byte, opts ...FromPemOption) (*x509.Certificate, error) { - options := fromPemOptions{} + options := fromPemOptions{ + onHit: nil, + onMiss: nil, + noCache: false, + } for _, opt := range opts { if opt != nil { opt(&options) diff --git a/internal/cmd/gtrace/main.go b/internal/cmd/gtrace/main.go index 41e96b24a..945b501a9 100644 --- a/internal/cmd/gtrace/main.go +++ b/internal/cmd/gtrace/main.go @@ -16,6 +16,7 @@ import ( "os" "path/filepath" "strings" + "sync" "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" ) @@ -82,11 +83,25 @@ func main() { writers = append(writers, &Writer{ Context: buildCtx, Output: f, + once: sync.Once{}, + bw: nil, + atEOL: false, + depth: 0, + scope: nil, + pkg: nil, + std: make(map[string]bool), }) } else { writers = append(writers, &Writer{ Context: buildCtx, Output: os.Stdout, + once: sync.Once{}, + bw: nil, + atEOL: false, + depth: 0, + scope: nil, + pkg: nil, + std: make(map[string]bool), }) } @@ -129,14 +144,25 @@ func main() { } } info := &types.Info{ - Types: make(map[ast.Expr]types.TypeAndValue), - Defs: make(map[*ast.Ident]types.Object), - Uses: make(map[*ast.Ident]types.Object), + Types: make(map[ast.Expr]types.TypeAndValue), + Defs: make(map[*ast.Ident]types.Object), + Uses: make(map[*ast.Ident]types.Object), + Instances: make(map[*ast.Ident]types.Instance), + Implicits: make(map[ast.Node]types.Object), + Selections: make(map[*ast.SelectorExpr]*types.Selection), + Scopes: make(map[ast.Node]*types.Scope), + InitOrder: nil, + FileVersions: make(map[*ast.File]string), } conf := types.Config{ IgnoreFuncBodies: true, DisableUnusedImportCheck: true, Importer: importer.ForCompiler(fset, "source", nil), + Context: nil, + GoVersion: "", + FakeImportC: false, + Error: nil, + Sizes: nil, } pkg, err := conf.Check(".", fset, astFiles, info) if err != nil { @@ -179,7 +205,7 @@ func main() { for _, c := range v.List { if strings.Contains(strings.TrimPrefix(c.Text, "//"), "gtrace:gen") { if item == nil { - item = &GenItem{} + item = &GenItem{Ident: nil, StructType: nil} } } } @@ -202,11 +228,14 @@ func main() { p := Package{ Package: pkg, BuildConstraints: buildConstraints, + Traces: nil, } traces := make(map[string]*Trace) for _, item := range items { t := &Trace{ - Name: item.Ident.Name, + Name: item.Ident.Name, + Hooks: nil, + Nested: false, } p.Traces = append(p.Traces, t) traces[item.Ident.Name] = t diff --git a/internal/conn/conn.go b/internal/conn/conn.go index c87e55c8f..e1b12c8db 100644 --- a/internal/conn/conn.go +++ b/internal/conn/conn.go @@ -432,6 +432,7 @@ func (c *conn) NewStream( s := &grpcClientStream{ parentConn: c, + stream: nil, streamCtx: ctx, streamCancel: cancel, wrapping: useWrapping, @@ -496,16 +497,21 @@ func withOnTransportError(onTransportError func(ctx context.Context, cc Conn, ca func newConn(e endpoint.Endpoint, config Config, opts ...option) *conn { c := &conn{ - endpoint: e, + mtx: sync.RWMutex{}, config: config, + grpcConn: nil, done: make(chan struct{}), - lastUsage: xsync.NewLastUsage(), + endpoint: e, + closed: false, + state: atomic.Uint32{}, childStreams: xcontext.NewCancelsGuard(), + lastUsage: xsync.NewLastUsage(), onClose: []func(*conn){ func(c *conn) { c.childStreams.Cancel() }, }, + onTransportErrors: nil, } c.state.Store(uint32(Created)) for _, opt := range opts { @@ -548,7 +554,9 @@ type ctxHandleRPCKey struct{} var rpcKey = ctxHandleRPCKey{} func markContext(ctx context.Context) (context.Context, *modificationMark) { - mark := &modificationMark{} + mark := &modificationMark{ + dirty: atomic.Bool{}, + } return context.WithValue(ctx, rpcKey, mark), mark } @@ -556,7 +564,9 @@ func markContext(ctx context.Context) (context.Context, *modificationMark) { func getContextMark(ctx context.Context) *modificationMark { v := ctx.Value(rpcKey) if v == nil { - return &modificationMark{} + return &modificationMark{ + dirty: atomic.Bool{}, + } } val, ok := v.(*modificationMark) diff --git a/internal/conn/pool.go b/internal/conn/pool.go index 783b7a880..75c215902 100644 --- a/internal/conn/pool.go +++ b/internal/conn/pool.go @@ -243,6 +243,7 @@ func NewPool(ctx context.Context, config Config) *Pool { opts: config.GrpcDialOptions(), conns: make(map[connsKey]*conn), done: make(chan struct{}), + mtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}, } if ttl := config.ConnectionTTL(); ttl > 0 { diff --git a/internal/coordination/client.go b/internal/coordination/client.go index c3685cc64..4ba4c538b 100644 --- a/internal/coordination/client.go +++ b/internal/coordination/client.go @@ -44,6 +44,7 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, config config.Config) config: config, client: Ydb_Coordination_V1.NewCoordinationServiceClient(cc), sessions: make(map[*session]struct{}), + mutex: sync.Mutex{}, } } diff --git a/internal/coordination/config/config.go b/internal/coordination/config/config.go index 692777a43..d473f4e7d 100644 --- a/internal/coordination/config/config.go +++ b/internal/coordination/config/config.go @@ -35,7 +35,8 @@ func With(config config.Common) Option { func New(opts ...Option) Config { c := Config{ - trace: &trace.Coordination{}, + Common: config.Common{}, + trace: new(trace.Coordination), } for _, opt := range opts { if opt != nil { diff --git a/internal/coordination/conversation/conversation.go b/internal/coordination/conversation/conversation.go index 83e170532..283bf9ff6 100644 --- a/internal/coordination/conversation/conversation.go +++ b/internal/coordination/conversation/conversation.go @@ -137,6 +137,9 @@ func NewController() *Controller { return &Controller{ notifyChan: make(chan struct{}, 1), conflicts: make(map[string]struct{}), + mutex: sync.Mutex{}, + queue: nil, + closed: false, } } @@ -195,7 +198,13 @@ type Option func(c *Conversation) // NewConversation creates a new conversation that starts with a specified message. func NewConversation(request func() *Ydb_Coordination.SessionRequest, opts ...Option) *Conversation { - conversation := Conversation{message: request} + conversation := Conversation{ + message: request, responseFilter: nil, acknowledgeFilter: nil, + cancelMessage: nil, cancelFilter: nil, + conflictKey: "", responseErr: nil, done: nil, + requestSent: nil, cancelRequestSent: nil, response: nil, + idempotent: false, canceled: false, + } for _, o := range opts { if o != nil { o(&conversation) diff --git a/internal/coordination/session.go b/internal/coordination/session.go index 5c6a17ac5..358ca2e64 100644 --- a/internal/coordination/session.go +++ b/internal/coordination/session.go @@ -49,12 +49,16 @@ func createSession( ) (*session, error) { sessionCtx, cancel := xcontext.WithCancel(xcontext.ValueOnly(ctx)) s := session{ - options: opts, - client: client, - ctx: sessionCtx, - cancel: cancel, - sessionClosedChan: make(chan struct{}), - controller: conversation.NewController(), + options: opts, + client: client, + ctx: sessionCtx, + cancel: cancel, + sessionClosedChan: make(chan struct{}), + controller: conversation.NewController(), + sessionID: 0, + mutex: sync.Mutex{}, + lastGoodResponseTime: time.Time{}, + cancelStream: nil, } client.sessionCreated(&s) @@ -548,6 +552,7 @@ func (s *session) CreateSemaphore( ReqId: newReqID(), Name: name, Limit: limit, + Data: nil, } for _, o := range opts { if o != nil { @@ -590,6 +595,7 @@ func (s *session) UpdateSemaphore( updateSemaphore := Ydb_Coordination.SessionRequest_UpdateSemaphore{ ReqId: newReqID(), Name: name, + Data: nil, } for _, o := range opts { if o != nil { @@ -634,6 +640,7 @@ func (s *session) DeleteSemaphore( deleteSemaphore := Ydb_Coordination.SessionRequest_DeleteSemaphore{ ReqId: newReqID(), Name: name, + Force: false, } for _, o := range opts { if o != nil { @@ -675,8 +682,12 @@ func (s *session) DescribeSemaphore( req := conversation.NewConversation( func() *Ydb_Coordination.SessionRequest { describeSemaphore := Ydb_Coordination.SessionRequest_DescribeSemaphore{ - ReqId: newReqID(), - Name: name, + ReqId: newReqID(), + Name: name, + IncludeOwners: false, + IncludeWaiters: false, + WatchData: false, + WatchOwners: false, } for _, o := range opts { if o != nil { @@ -778,6 +789,8 @@ func (s *session) AcquireSemaphore( Name: name, Count: count, TimeoutMillis: math.MaxUint64, + Data: nil, + Ephemeral: false, } for _, o := range opts { if o != nil { diff --git a/internal/credentials/access_error_test.go b/internal/credentials/access_error_test.go index 565ad8975..468c777eb 100644 --- a/internal/credentials/access_error_test.go +++ b/internal/credentials/access_error_test.go @@ -14,7 +14,7 @@ import ( "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" ) -var _ Credentials = customCredentials{} +var _ Credentials = customCredentials{token: ""} type customCredentials struct { token string diff --git a/internal/credentials/oauth2.go b/internal/credentials/oauth2.go index 1fc5da7d3..b45e052bd 100644 --- a/internal/credentials/oauth2.go +++ b/internal/credentials/oauth2.go @@ -179,12 +179,14 @@ func (tokenSource *tokenSourceOption) ApplyOauth2CredentialsOption(c *oauth2Toke func WithSubjectToken(subjectToken TokenSource) *tokenSourceOption { return &tokenSourceOption{ source: subjectToken, + createFunc: nil, tokenSourceType: SubjectTokenSourceType, } } func WithFixedSubjectToken(token, tokenType string) *tokenSourceOption { return &tokenSourceOption{ + source: nil, createFunc: func() (TokenSource, error) { return NewFixedTokenSource(token, tokenType), nil }, @@ -194,6 +196,7 @@ func WithFixedSubjectToken(token, tokenType string) *tokenSourceOption { func WithJWTSubjectToken(opts ...JWTTokenSourceOption) *tokenSourceOption { return &tokenSourceOption{ + source: nil, createFunc: func() (TokenSource, error) { return NewJWTTokenSource(opts...) }, @@ -205,12 +208,14 @@ func WithJWTSubjectToken(opts ...JWTTokenSourceOption) *tokenSourceOption { func WithActorToken(actorToken TokenSource) *tokenSourceOption { return &tokenSourceOption{ source: actorToken, + createFunc: nil, tokenSourceType: ActorTokenSourceType, } } func WithFixedActorToken(token, tokenType string) *tokenSourceOption { return &tokenSourceOption{ + source: nil, createFunc: func() (TokenSource, error) { return NewFixedTokenSource(token, tokenType), nil }, @@ -220,6 +225,7 @@ func WithFixedActorToken(token, tokenType string) *tokenSourceOption { func WithJWTActorToken(opts ...JWTTokenSourceOption) *tokenSourceOption { return &tokenSourceOption{ + source: nil, createFunc: func() (TokenSource, error) { return NewJWTTokenSource(opts...) }, @@ -265,10 +271,21 @@ func NewOauth2TokenExchangeCredentials( opts ...Oauth2TokenExchangeCredentialsOption, ) (*oauth2TokenExchange, error) { c := &oauth2TokenExchange{ - grantType: "urn:ietf:params:oauth:grant-type:token-exchange", - requestedTokenType: "urn:ietf:params:oauth:token-type:access_token", - requestTimeout: defaultRequestTimeout, - sourceInfo: stack.Record(1), + tokenEndpoint: "", + grantType: "urn:ietf:params:oauth:grant-type:token-exchange", + resource: "", + audience: nil, + scope: nil, + requestedTokenType: "urn:ietf:params:oauth:token-type:access_token", + subjectTokenSource: nil, + actorTokenSource: nil, + requestTimeout: defaultRequestTimeout, + receivedToken: "", + updateTokenTime: time.Time{}, + receivedTokenExpireTime: time.Time{}, + mutex: sync.RWMutex{}, + updating: atomic.Bool{}, + sourceInfo: stack.Record(1), } var err error @@ -478,8 +495,10 @@ func (provider *oauth2TokenExchange) exchangeToken(ctx context.Context, now time req.Close = true client := http.Client{ - Transport: http.DefaultTransport, - Timeout: provider.requestTimeout, + Transport: http.DefaultTransport, + CheckRedirect: nil, + Jar: nil, + Timeout: provider.requestTimeout, } result, err := client.Do(req) @@ -782,7 +801,14 @@ func WithRSAPrivateKeyPEMFile(path string) *rsaPrivateKeyPemFileOption { func NewJWTTokenSource(opts ...JWTTokenSourceOption) (*jwtTokenSource, error) { s := &jwtTokenSource{ - tokenTTL: defaultJWTTokenTTL, + signingMethod: nil, + keyID: "", + privateKey: nil, + issuer: "", + subject: "", + audience: nil, + id: "", + tokenTTL: defaultJWTTokenTTL, } var err error @@ -827,6 +853,8 @@ func (s *jwtTokenSource) Token() (Token, error) { err error ) t := jwt.Token{ + Raw: "", + Method: s.signingMethod, Header: map[string]interface{}{ "typ": "JWT", "alg": s.signingMethod.Alg(), @@ -838,9 +866,11 @@ func (s *jwtTokenSource) Token() (Token, error) { IssuedAt: issued, Audience: s.audience, ExpiresAt: expire, + NotBefore: nil, ID: s.id, }, - Method: s.signingMethod, + Signature: "", + Valid: false, } var token Token diff --git a/internal/credentials/static.go b/internal/credentials/static.go index 5c6328992..dfc756507 100644 --- a/internal/credentials/static.go +++ b/internal/credentials/static.go @@ -46,6 +46,10 @@ func NewStaticCredentials(user, password, endpoint string, opts ...StaticCredent user: user, password: password, endpoint: endpoint, + opts: []grpc.DialOption{}, + token: "", + requestAt: time.Time{}, + mu: sync.Mutex{}, sourceInfo: stack.Record(1), } for _, opt := range opts { diff --git a/internal/discovery/config/config.go b/internal/discovery/config/config.go index 2726b4238..8aa8ced3b 100644 --- a/internal/discovery/config/config.go +++ b/internal/discovery/config/config.go @@ -30,12 +30,17 @@ type Config struct { func New(opts ...Option) *Config { c := &Config{ - interval: DefaultInterval, - trace: &trace.Discovery{}, + Common: config.Common{}, + endpoint: "", + database: "", + secure: false, + meta: nil, addressMutator: func(address string) string { return address }, - clock: clockwork.NewRealClock(), + clock: clockwork.NewRealClock(), + interval: DefaultInterval, + trace: new(trace.Discovery), } for _, opt := range opts { if opt != nil { diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 82797cfaf..cf23a99ba 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -29,7 +29,7 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, config *config.Config } } -var _ discovery.Client = &Client{} +var _ discovery.Client = &Client{config: nil, cc: nil, client: nil} type Client struct { config *config.Config @@ -45,6 +45,7 @@ func discover( var ( request = Ydb_Discovery.ListEndpointsRequest{ Database: config.Database(), + Service: nil, } response *Ydb_Discovery.ListEndpointsResponse result Ydb_Discovery.ListEndpointsResult @@ -124,7 +125,7 @@ func (c *Client) WhoAmI(ctx context.Context) (whoAmI *discovery.WhoAmI, err erro onDone = trace.DiscoveryOnWhoAmI(c.config.Trace(), &ctx, stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/discovery.(*Client).WhoAmI"), ) - request = Ydb_Discovery.WhoAmIRequest{} + request = Ydb_Discovery.WhoAmIRequest{IncludeGroups: false} response *Ydb_Discovery.WhoAmIResponse whoAmIResultResult Ydb_Discovery.WhoAmIResult ) @@ -156,7 +157,7 @@ func (c *Client) WhoAmI(ctx context.Context) (whoAmI *discovery.WhoAmI, err erro result := response.GetOperation().GetResult() if result == nil { - return &discovery.WhoAmI{}, nil + return &discovery.WhoAmI{User: "", Groups: nil}, nil } err = response.GetOperation().GetResult().UnmarshalTo(&whoAmIResultResult) diff --git a/internal/endpoint/endpoint.go b/internal/endpoint/endpoint.go index ca65fae95..f3007b8d3 100644 --- a/internal/endpoint/endpoint.go +++ b/internal/endpoint/endpoint.go @@ -46,6 +46,7 @@ func (e *endpoint) Copy() Endpoint { defer e.mu.RUnlock() return &endpoint{ + mu: sync.RWMutex{}, id: e.id, address: e.address, location: e.location, @@ -166,7 +167,13 @@ func WithLastUpdated(ts time.Time) Option { func New(address string, opts ...Option) *endpoint { e := &endpoint{ + mu: sync.RWMutex{}, + id: 0, address: address, + location: "", + services: []string{}, + loadFactor: 0, + local: false, lastUpdated: time.Now(), } for _, opt := range opts { diff --git a/internal/grpcwrapper/rawtopic/alter_topic.go b/internal/grpcwrapper/rawtopic/alter_topic.go index d7db57d74..c78f307ab 100644 --- a/internal/grpcwrapper/rawtopic/alter_topic.go +++ b/internal/grpcwrapper/rawtopic/alter_topic.go @@ -34,9 +34,13 @@ func (req *AlterTopicRequest) ToProto() *Ydb_Topic.AlterTopicRequest { AlterPartitioningSettings: req.AlterPartitionSettings.ToProto(), SetRetentionPeriod: req.SetRetentionPeriod.ToProto(), SetRetentionStorageMb: req.SetRetentionStorageMB.ToProto(), + SetSupportedCodecs: req.SetSupportedCodecsValue.ToProto(), SetPartitionWriteSpeedBytesPerSecond: req.SetPartitionWriteSpeedBytesPerSecond.ToProto(), SetPartitionWriteBurstBytes: req.SetPartitionWriteBurstBytes.ToProto(), AlterAttributes: req.AlterAttributes, + AddConsumers: []*Ydb_Topic.Consumer{}, + DropConsumers: []string{}, + AlterConsumers: []*Ydb_Topic.AlterConsumer{}, SetMeteringMode: Ydb_Topic.MeteringMode(req.SetMeteringMode), } diff --git a/internal/grpcwrapper/rawtopic/controlplane_types.go b/internal/grpcwrapper/rawtopic/controlplane_types.go index 6df4322fb..6940958d1 100644 --- a/internal/grpcwrapper/rawtopic/controlplane_types.go +++ b/internal/grpcwrapper/rawtopic/controlplane_types.go @@ -35,6 +35,7 @@ func (c *Consumer) ToProto() *Ydb_Topic.Consumer { ReadFrom: c.ReadFrom.ToProto(), SupportedCodecs: c.SupportedCodecs.ToProto(), Attributes: c.Attributes, + ConsumerStats: new(Ydb_Topic.Consumer_ConsumerStats), } } diff --git a/internal/grpcwrapper/rawtopic/create_topic.go b/internal/grpcwrapper/rawtopic/create_topic.go index fd17da84e..e23035eae 100644 --- a/internal/grpcwrapper/rawtopic/create_topic.go +++ b/internal/grpcwrapper/rawtopic/create_topic.go @@ -27,26 +27,27 @@ type CreateTopicRequest struct { func (req *CreateTopicRequest) ToProto() *Ydb_Topic.CreateTopicRequest { proto := &Ydb_Topic.CreateTopicRequest{ - Path: req.Path, - PartitioningSettings: req.PartitionSettings.ToProto(), + OperationParams: req.OperationParams.ToProto(), + Path: req.Path, + PartitioningSettings: req.PartitionSettings.ToProto(), + RetentionPeriod: new(durationpb.Duration), + RetentionStorageMb: req.RetentionStorageMB, + SupportedCodecs: req.SupportedCodecs.ToProto(), + PartitionWriteSpeedBytesPerSecond: req.PartitionWriteSpeedBytesPerSecond, + PartitionWriteBurstBytes: req.PartitionWriteBurstBytes, + Attributes: req.Attributes, + Consumers: make([]*Ydb_Topic.Consumer, len(req.Consumers)), + MeteringMode: Ydb_Topic.MeteringMode(req.MeteringMode), } if req.RetentionPeriod != 0 { proto.RetentionPeriod = durationpb.New(req.RetentionPeriod) } - proto.RetentionStorageMb = req.RetentionStorageMB - proto.SupportedCodecs = req.SupportedCodecs.ToProto() - proto.PartitionWriteSpeedBytesPerSecond = req.PartitionWriteSpeedBytesPerSecond - proto.PartitionWriteBurstBytes = req.PartitionWriteBurstBytes - proto.Attributes = req.Attributes - proto.Consumers = make([]*Ydb_Topic.Consumer, len(req.Consumers)) for i := range proto.GetConsumers() { proto.Consumers[i] = req.Consumers[i].ToProto() } - proto.MeteringMode = Ydb_Topic.MeteringMode(req.MeteringMode) - return proto } diff --git a/internal/grpcwrapper/rawtopic/describe_topic.go b/internal/grpcwrapper/rawtopic/describe_topic.go index a1c3d4838..9d040e04f 100644 --- a/internal/grpcwrapper/rawtopic/describe_topic.go +++ b/internal/grpcwrapper/rawtopic/describe_topic.go @@ -22,6 +22,7 @@ func (req *DescribeTopicRequest) ToProto() *Ydb_Topic.DescribeTopicRequest { return &Ydb_Topic.DescribeTopicRequest{ OperationParams: req.OperationParams.ToProto(), Path: req.Path, + IncludeStats: false, } } @@ -46,7 +47,7 @@ func (res *DescribeTopicResult) FromProto(protoResponse *Ydb_Topic.DescribeTopic return err } - protoResult := &Ydb_Topic.DescribeTopicResult{} + protoResult := new(Ydb_Topic.DescribeTopicResult) if err := protoResponse.GetOperation().GetResult().UnmarshalTo(protoResult); err != nil { return xerrors.WithStackTrace(fmt.Errorf("ydb: describe topic result failed on unmarshal grpc result: %w", err)) } diff --git a/internal/grpcwrapper/rawtopic/rawtopicreader/messages.go b/internal/grpcwrapper/rawtopic/rawtopicreader/messages.go index cea9072d1..d242d8691 100644 --- a/internal/grpcwrapper/rawtopic/rawtopicreader/messages.go +++ b/internal/grpcwrapper/rawtopic/rawtopicreader/messages.go @@ -111,13 +111,14 @@ type InitRequest struct { func (r *InitRequest) toProto() *Ydb_Topic.StreamReadMessage_InitRequest { p := &Ydb_Topic.StreamReadMessage_InitRequest{ - Consumer: r.Consumer, + Consumer: r.Consumer, + TopicsReadSettings: make([]*Ydb_Topic.StreamReadMessage_InitRequest_TopicReadSettings, len(r.TopicsReadSettings)), + ReaderName: "", } - p.TopicsReadSettings = make([]*Ydb_Topic.StreamReadMessage_InitRequest_TopicReadSettings, len(r.TopicsReadSettings)) for topicSettingsIndex := range r.TopicsReadSettings { srcTopicSettings := &r.TopicsReadSettings[topicSettingsIndex] - dstTopicSettings := &Ydb_Topic.StreamReadMessage_InitRequest_TopicReadSettings{} + dstTopicSettings := new(Ydb_Topic.StreamReadMessage_InitRequest_TopicReadSettings) p.TopicsReadSettings[topicSettingsIndex] = dstTopicSettings dstTopicSettings.Path = srcTopicSettings.Path @@ -306,20 +307,21 @@ type CommitOffsetRequest struct { } func (r *CommitOffsetRequest) toProto() *Ydb_Topic.StreamReadMessage_CommitOffsetRequest { - res := &Ydb_Topic.StreamReadMessage_CommitOffsetRequest{} - res.CommitOffsets = make( - []*Ydb_Topic.StreamReadMessage_CommitOffsetRequest_PartitionCommitOffset, - len(r.CommitOffsets), - ) + res := &Ydb_Topic.StreamReadMessage_CommitOffsetRequest{ + CommitOffsets: make( + []*Ydb_Topic.StreamReadMessage_CommitOffsetRequest_PartitionCommitOffset, + len(r.CommitOffsets), + ), + } for sessionIndex := range r.CommitOffsets { srcPartitionCommitOffset := &r.CommitOffsets[sessionIndex] dstCommitOffset := &Ydb_Topic.StreamReadMessage_CommitOffsetRequest_PartitionCommitOffset{ PartitionSessionId: srcPartitionCommitOffset.PartitionSessionID.ToInt64(), + Offsets: make([]*Ydb_Topic.OffsetsRange, len(srcPartitionCommitOffset.Offsets)), } res.CommitOffsets[sessionIndex] = dstCommitOffset - dstCommitOffset.Offsets = make([]*Ydb_Topic.OffsetsRange, len(srcPartitionCommitOffset.Offsets)) for offsetIndex := range srcPartitionCommitOffset.Offsets { dstCommitOffset.Offsets[offsetIndex] = srcPartitionCommitOffset.Offsets[offsetIndex].ToProto() } diff --git a/internal/grpcwrapper/rawtopic/rawtopicreader/rawtopicreader.go b/internal/grpcwrapper/rawtopic/rawtopicreader/rawtopicreader.go index 17ccc026e..db2a7f461 100644 --- a/internal/grpcwrapper/rawtopic/rawtopicreader/rawtopicreader.go +++ b/internal/grpcwrapper/rawtopic/rawtopicreader/rawtopicreader.go @@ -52,13 +52,13 @@ func (s StreamReader) Recv() (ServerMessage, error) { switch m := grpcMess.GetServerMessage().(type) { case *Ydb_Topic.StreamReadMessage_FromServer_InitResponse: - resp := &InitResponse{} + resp := new(InitResponse) resp.ServerMessageMetadata = meta resp.fromProto(m.InitResponse) return resp, nil case *Ydb_Topic.StreamReadMessage_FromServer_ReadResponse: - resp := &ReadResponse{} + resp := new(ReadResponse) resp.ServerMessageMetadata = meta if err = resp.fromProto(m.ReadResponse); err != nil { return nil, err @@ -66,7 +66,7 @@ func (s StreamReader) Recv() (ServerMessage, error) { return resp, nil case *Ydb_Topic.StreamReadMessage_FromServer_StartPartitionSessionRequest: - resp := &StartPartitionSessionRequest{} + resp := new(StartPartitionSessionRequest) resp.ServerMessageMetadata = meta if err = resp.fromProto(m.StartPartitionSessionRequest); err != nil { return nil, err @@ -74,7 +74,7 @@ func (s StreamReader) Recv() (ServerMessage, error) { return resp, nil case *Ydb_Topic.StreamReadMessage_FromServer_StopPartitionSessionRequest: - req := &StopPartitionSessionRequest{} + req := new(StopPartitionSessionRequest) req.ServerMessageMetadata = meta if err = req.fromProto(m.StopPartitionSessionRequest); err != nil { return nil, err @@ -82,7 +82,7 @@ func (s StreamReader) Recv() (ServerMessage, error) { return req, nil case *Ydb_Topic.StreamReadMessage_FromServer_CommitOffsetResponse: - resp := &CommitOffsetResponse{} + resp := new(CommitOffsetResponse) resp.ServerMessageMetadata = meta if err = resp.fromProto(m.CommitOffsetResponse); err != nil { return nil, err @@ -90,7 +90,7 @@ func (s StreamReader) Recv() (ServerMessage, error) { return resp, nil case *Ydb_Topic.StreamReadMessage_FromServer_PartitionSessionStatusResponse: - resp := &PartitionSessionStatusResponse{} + resp := new(PartitionSessionStatusResponse) resp.ServerMessageMetadata = meta if err = resp.fromProto(m.PartitionSessionStatusResponse); err != nil { return nil, err @@ -98,7 +98,7 @@ func (s StreamReader) Recv() (ServerMessage, error) { return resp, nil case *Ydb_Topic.StreamReadMessage_FromServer_UpdateTokenResponse: - resp := &UpdateTokenResponse{} + resp := new(UpdateTokenResponse) resp.ServerMessageMetadata = meta resp.MustFromProto(m.UpdateTokenResponse) diff --git a/internal/grpcwrapper/rawtopic/rawtopicwriter/messages.go b/internal/grpcwrapper/rawtopic/rawtopicwriter/messages.go index 252b4b3cb..bf7181b63 100644 --- a/internal/grpcwrapper/rawtopic/rawtopicwriter/messages.go +++ b/internal/grpcwrapper/rawtopic/rawtopicwriter/messages.go @@ -37,6 +37,7 @@ func (r *InitRequest) toProto() (*Ydb_Topic.StreamWriteMessage_InitRequest, erro ProducerId: r.ProducerID, WriteSessionMeta: r.WriteSessionMeta, GetLastSeqNo: r.GetLastSeqNo, + Partitioning: nil, } err := r.Partitioning.setToProtoInitRequest(res) @@ -60,13 +61,15 @@ func NewPartitioningMessageGroup(messageGroupID string) Partitioning { return Partitioning{ Type: PartitioningMessageGroupID, MessageGroupID: messageGroupID, + PartitionID: 0, } } func NewPartitioningPartitionID(partitionID int64) Partitioning { return Partitioning{ - Type: PartitioningPartitionID, - PartitionID: partitionID, + Type: PartitioningPartitionID, + MessageGroupID: "", + PartitionID: partitionID, } } @@ -160,6 +163,7 @@ func (r *WriteRequest) toProto() (p *Ydb_Topic.StreamWriteMessage_FromClient_Wri WriteRequest: &Ydb_Topic.StreamWriteMessage_WriteRequest{ Messages: messages, Codec: int32(r.Codec.ToProto()), + Tx: new(Ydb_Topic.TransactionIdentity), }, } @@ -181,6 +185,8 @@ func (d *MessageData) ToProto() (*Ydb_Topic.StreamWriteMessage_WriteRequest_Mess CreatedAt: timestamppb.New(d.CreatedAt), Data: d.Data, UncompressedSize: d.UncompressedSize, + Partitioning: nil, + MetadataItems: []*Ydb_Topic.MetadataItem{}, } err := d.Partitioning.setToProtoMessage(res) if err != nil { diff --git a/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go b/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go index f076adab9..f986eb0d5 100644 --- a/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go +++ b/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go @@ -19,6 +19,7 @@ func TestSendWriteRequest(t *testing.T) { SeqNo: 1, }, }, + Tx: new(Ydb_Topic.TransactionIdentity), }, } @@ -48,6 +49,7 @@ func TestSendWriteRequest(t *testing.T) { SeqNo: 3, }, }, + Tx: new(Ydb_Topic.TransactionIdentity), } split1 := &Ydb_Topic.StreamWriteMessage_WriteRequest{ @@ -57,6 +59,7 @@ func TestSendWriteRequest(t *testing.T) { SeqNo: 1, }, }, + Tx: new(Ydb_Topic.TransactionIdentity), } split2 := &Ydb_Topic.StreamWriteMessage_WriteRequest{ @@ -69,6 +72,7 @@ func TestSendWriteRequest(t *testing.T) { SeqNo: 3, }, }, + Tx: new(Ydb_Topic.TransactionIdentity), } getWriteRequest := func(req *Ydb_Topic.StreamWriteMessage_FromClient) *Ydb_Topic.StreamWriteMessage_WriteRequest { diff --git a/internal/grpcwrapper/rawydb/operation_params.go b/internal/grpcwrapper/rawydb/operation_params.go index 21d80eba1..c80bb99b5 100644 --- a/internal/grpcwrapper/rawydb/operation_params.go +++ b/internal/grpcwrapper/rawydb/operation_params.go @@ -1,6 +1,7 @@ package rawydb import ( + "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Operations" "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawoptional" @@ -15,10 +16,12 @@ type OperationParams struct { func (p *OperationParams) ToProto() *Ydb_Operations.OperationParams { res := &Ydb_Operations.OperationParams{ - OperationMode: p.OperationMode.ToProto(), + OperationMode: p.OperationMode.ToProto(), + OperationTimeout: p.OperationTimeout.ToProto(), + CancelAfter: p.CancelAfter.ToProto(), + Labels: make(map[string]string), + ReportCostInfo: Ydb.FeatureFlag_STATUS_UNSPECIFIED, } - res.OperationTimeout = p.OperationTimeout.ToProto() - res.CancelAfter = p.CancelAfter.ToProto() return res } diff --git a/internal/meta/meta.go b/internal/meta/meta.go index 8f856379d..ccf244c8e 100644 --- a/internal/meta/meta.go +++ b/internal/meta/meta.go @@ -24,10 +24,13 @@ func New( opts ...Option, ) *Meta { m := &Meta{ - pid: strconv.Itoa(pid), - trace: trace, - credentials: credentials, - database: database, + pid: strconv.Itoa(pid), + trace: trace, + credentials: credentials, + database: database, + requestsType: "", + applicationName: "", + capabilities: nil, } for _, opt := range opts { if opt != nil { diff --git a/internal/meta/test/meta_test.go b/internal/meta/test/meta_test.go index 139187ef6..81a24d218 100644 --- a/internal/meta/test/meta_test.go +++ b/internal/meta/test/meta_test.go @@ -18,7 +18,7 @@ func TestMetaRequiredHeaders(t *testing.T) { m := internal.New( "database", credentials.NewAccessTokenCredentials("token"), - &trace.Driver{}, + new(trace.Driver), internal.WithRequestTypeOption("requestType"), internal.WithApplicationNameOption("test app"), ) diff --git a/internal/operation/params.go b/internal/operation/params.go index 03d342e9a..915a0b3a7 100644 --- a/internal/operation/params.go +++ b/internal/operation/params.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Operations" ) @@ -30,5 +31,7 @@ func Params( OperationMode: mode.toYDB(), OperationTimeout: timeoutParam(timeout), CancelAfter: timeoutParam(cancelAfter), + Labels: nil, + ReportCostInfo: Ydb.FeatureFlag_STATUS_UNSPECIFIED, } } diff --git a/internal/params/dict.go b/internal/params/dict.go index d772f659e..e9128325e 100644 --- a/internal/params/dict.go +++ b/internal/params/dict.go @@ -23,7 +23,8 @@ type ( func (d *dict) Add() *dictPair { return &dictPair{ - parent: d, + parent: d, + keyValue: nil, } } diff --git a/internal/params/parameters.go b/internal/params/parameters.go index aae4e38d0..4508da16d 100644 --- a/internal/params/parameters.go +++ b/internal/params/parameters.go @@ -26,6 +26,9 @@ type ( func Named(name string, value value.Value) *Parameter { return &Parameter{ + parent: Builder{ + params: nil, + }, name: name, value: value, } @@ -99,6 +102,7 @@ func (p *Parameter) BeginOptional() *optional { return &optional{ parent: p.parent, name: p.name, + value: p.value, } } @@ -106,6 +110,7 @@ func (p *Parameter) BeginList() *list { return &list{ parent: p.parent, name: p.name, + values: nil, } } @@ -117,6 +122,7 @@ func (p *Parameter) BeginSet() *set { return &set{ parent: p.parent, name: p.name, + values: nil, } } @@ -124,6 +130,7 @@ func (p *Parameter) BeginDict() *dict { return &dict{ parent: p.parent, name: p.name, + values: nil, } } @@ -131,6 +138,7 @@ func (p *Parameter) BeginTuple() *tuple { return &tuple{ parent: p.parent, name: p.name, + values: nil, } } @@ -138,6 +146,7 @@ func (p *Parameter) BeginStruct() *structure { return &structure{ parent: p.parent, name: p.name, + values: nil, } } @@ -145,6 +154,7 @@ func (p *Parameter) BeginVariant() *variant { return &variant{ parent: p.parent, name: p.name, + value: p.value, } } diff --git a/internal/params/variant.go b/internal/params/variant.go index 16815e38e..fbe3ff543 100644 --- a/internal/params/variant.go +++ b/internal/params/variant.go @@ -27,11 +27,17 @@ func (vb *variantBuilder) EndVariant() Builder { func (v *variant) BeginTuple() *variantTuple { return &variantTuple{ parent: v, + types: nil, + index: 0, + value: v.value, } } func (v *variant) BeginStruct() *variantStruct { return &variantStruct{ parent: v, + fields: nil, + name: "", + value: v.value, } } diff --git a/internal/pool/pool.go b/internal/pool/pool.go index 3368aadc8..ee675a62d 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -2,6 +2,7 @@ package pool import ( "context" + "sync" "time" "golang.org/x/sync/errgroup" @@ -147,14 +148,20 @@ func New[PT Item[T], T any]( opts ...option[PT, T], ) *Pool[PT, T] { p := &Pool[PT, T]{ - trace: defaultTrace, - limit: DefaultLimit, + trace: defaultTrace, + limit: DefaultLimit, + createTimeout: time.Duration(0), + closeTimeout: time.Duration(0), + mu: xsync.Mutex{Mutex: sync.Mutex{}}, + idle: nil, + index: nil, createItem: func(ctx context.Context) (PT, error) { var item T return &item, nil }, - done: make(chan struct{}), + done: make(chan struct{}), + stats: nil, } for _, opt := range opts { @@ -252,7 +259,8 @@ func New[PT Item[T], T any]( p.idle = make([]PT, 0, p.limit) p.index = make(map[PT]struct{}, p.limit) p.stats = &safeStats{ - v: stats.Stats{Limit: p.limit}, + mu: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + v: stats.Stats{Limit: p.limit, Index: 0, Idle: 0, InUse: 0}, onChange: p.trace.OnChange, } diff --git a/internal/query/client.go b/internal/query/client.go index 3019e83cd..a501a43a9 100644 --- a/internal/query/client.go +++ b/internal/query/client.go @@ -175,6 +175,7 @@ func New(ctx context.Context, balancer balancer, cfg *config.Config) *Client { client := &Client{ config: cfg, grpcClient: Ydb_Query_V1.NewQueryServiceClient(balancer), + pool: nil, done: make(chan struct{}), } diff --git a/internal/query/config/config.go b/internal/query/config/config.go index 7adb08242..8aca2ed3e 100644 --- a/internal/query/config/config.go +++ b/internal/query/config/config.go @@ -38,10 +38,11 @@ func New(opts ...Option) *Config { func defaults() *Config { return &Config{ + Common: config.Common{}, poolLimit: DefaultPoolMaxSize, sessionCreateTimeout: DefaultSessionCreateTimeout, sessionDeleteTimeout: DefaultSessionDeleteTimeout, - trace: &trace.Query{}, + trace: new(trace.Query), } } diff --git a/internal/query/options/execute.go b/internal/query/options/execute.go index 6a306c26d..7352fedc6 100644 --- a/internal/query/options/execute.go +++ b/internal/query/options/execute.go @@ -112,15 +112,18 @@ const ( func defaultCommonExecuteSettings() commonExecuteSettings { return commonExecuteSettings{ - syntax: SyntaxYQL, - execMode: ExecModeExecute, - statsMode: StatsModeNone, + syntax: SyntaxYQL, + params: params.Parameters{}, + execMode: ExecModeExecute, + statsMode: StatsModeNone, + callOptions: nil, } } func ExecuteSettings(opts ...ExecuteOption) (settings *Execute) { settings = &Execute{ commonExecuteSettings: defaultCommonExecuteSettings(), + txControl: nil, } settings.commonExecuteSettings = defaultCommonExecuteSettings() settings.txControl = tx.DefaultTxControl() @@ -168,6 +171,7 @@ func (s *commonExecuteSettings) Params() *params.Parameters { func TxExecuteSettings(id string, opts ...TxExecuteOption) (settings *txExecuteSettings) { settings = &txExecuteSettings{ ExecuteSettings: ExecuteSettings(WithTxControl(tx.NewControl(tx.WithTxID(id)))), + commitTx: false, } for _, opt := range opts { if opt != nil { @@ -190,7 +194,7 @@ var ( _ TxExecuteOption = ExecMode(0) _ TxExecuteOption = StatsMode(0) _ TxExecuteOption = txCommitOption{} - _ ExecuteOption = TxControlOption{} + _ ExecuteOption = TxControlOption{txControl: nil} ) func WithCommit() txCommitOption { diff --git a/internal/query/options/retry.go b/internal/query/options/retry.go index a5fe4f8d2..61192ba53 100644 --- a/internal/query/options/retry.go +++ b/internal/query/options/retry.go @@ -9,11 +9,11 @@ import ( var ( _ DoOption = retryOptionsOption(nil) - _ DoOption = traceOption{} + _ DoOption = traceOption{t: nil} _ DoTxOption = retryOptionsOption(nil) - _ DoTxOption = traceOption{} - _ DoTxOption = doTxSettingsOption{} + _ DoTxOption = traceOption{t: nil} + _ DoTxOption = doTxSettingsOption{txSettings: nil} ) type ( @@ -102,7 +102,8 @@ func WithRetryBudget(b budget.Budget) retryOptionsOption { func ParseDoOpts(t *trace.Query, opts ...DoOption) (s *doSettings) { s = &doSettings{ - trace: t, + retryOpts: nil, + trace: t, } for _, opt := range opts { diff --git a/internal/query/result.go b/internal/query/result.go index b9c563570..bd691471e 100644 --- a/internal/query/result.go +++ b/internal/query/result.go @@ -34,7 +34,7 @@ func newResult( closeResult context.CancelFunc, ) (_ *result, txID string, err error) { if t == nil { - t = &trace.Query{} + t = new(trace.Query) } if closeResult == nil { closeResult = func() {} @@ -74,6 +74,7 @@ func newResult( lastPart: part, closed: closed, closeOnce: closeOnce, + errs: nil, trace: t, }, part.GetTxMeta().GetId(), nil } @@ -85,7 +86,7 @@ func nextPart( t *trace.Query, ) (_ *Ydb_Query.ExecuteQueryResponsePart, finalErr error) { if t == nil { - t = &trace.Query{} + t = new(trace.Query) } onDone := trace.QueryOnResultNextPart(t, &ctx, diff --git a/internal/query/result_set.go b/internal/query/result_set.go index 8d2ae8b71..a110c727a 100644 --- a/internal/query/result_set.go +++ b/internal/query/result_set.go @@ -32,7 +32,7 @@ func newResultSet( t *trace.Query, ) *resultSet { if t == nil { - t = &trace.Query{} + t = new(trace.Query) } return &resultSet{ diff --git a/internal/query/session.go b/internal/query/session.go index e2b2ab8cf..8b36d2054 100644 --- a/internal/query/session.go +++ b/internal/query/session.go @@ -45,8 +45,11 @@ func createSession( ) (s *Session, finalErr error) { s = &Session{ cfg: cfg, + id: "", + nodeID: 0, grpcClient: client, statusCode: statusUnknown, + closeOnce: nil, checks: []func(*Session) bool{ func(s *Session) bool { switch s.status() { diff --git a/internal/ratelimiter/client.go b/internal/ratelimiter/client.go index c1db4c0ce..1c589616c 100644 --- a/internal/ratelimiter/client.go +++ b/internal/ratelimiter/client.go @@ -304,6 +304,10 @@ func (c *Client) describeResource( resource := &ratelimiter.Resource{ ResourcePath: result.GetResource().GetResourcePath(), + HierarchicalDrr: ratelimiter.HierarchicalDrrSettings{ + MaxUnitsPerSecond: 0, MaxBurstSizeCoefficient: 0, + PrefetchCoefficient: 0, PrefetchWatermark: 0, + }, } if result.GetResource().GetHierarchicalDrr() != nil { diff --git a/internal/ratelimiter/config/config.go b/internal/ratelimiter/config/config.go index d0761f779..4a73236e3 100644 --- a/internal/ratelimiter/config/config.go +++ b/internal/ratelimiter/config/config.go @@ -35,7 +35,8 @@ func With(config config.Common) Option { func New(opts ...Option) Config { c := Config{ - trace: &trace.Ratelimiter{}, + Common: config.Common{}, + trace: &trace.Ratelimiter{}, } for _, opt := range opts { if opt != nil { diff --git a/internal/ratelimiter/options/acquire.go b/internal/ratelimiter/options/acquire.go index 1febf3e63..d502c01b8 100644 --- a/internal/ratelimiter/options/acquire.go +++ b/internal/ratelimiter/options/acquire.go @@ -72,7 +72,9 @@ func WithOperationCancelAfter(operationCancelAfter time.Duration) AcquireOption func NewAcquire(opts ...AcquireOption) Acquire { h := &acquireOptionsHolder{ - acquireType: AcquireTypeDefault, + acquireType: AcquireTypeDefault, + operationTimeout: time.Duration(0), + operationCancelAfter: time.Duration(0), } for _, opt := range opts { if opt != nil { diff --git a/internal/repeater/repeater.go b/internal/repeater/repeater.go index ec75be3c1..5f31a6f60 100644 --- a/internal/repeater/repeater.go +++ b/internal/repeater/repeater.go @@ -100,12 +100,13 @@ func New( r := &repeater{ interval: interval, + name: "", + trace: new(trace.Driver), task: task, cancel: cancel, stopped: make(chan struct{}), force: make(chan struct{}, 1), clock: clockwork.NewRealClock(), - trace: &trace.Driver{}, } for _, opt := range opts { diff --git a/internal/scheme/client.go b/internal/scheme/client.go index 154c44eed..fdde9d154 100644 --- a/internal/scheme/client.go +++ b/internal/scheme/client.go @@ -289,6 +289,7 @@ func (c *Client) modifyPermissions(ctx context.Context, path string, desc permis c.config.OperationCancelAfter(), operation.ModeSync, ), + Inheritance: nil, }, ) if err != nil { diff --git a/internal/scheme/config/config.go b/internal/scheme/config/config.go index 13865ffba..4e67a3440 100644 --- a/internal/scheme/config/config.go +++ b/internal/scheme/config/config.go @@ -48,7 +48,9 @@ func With(config config.Common) Option { func New(opts ...Option) *Config { c := &Config{ - trace: &trace.Scheme{}, + Common: config.Common{}, + databaseName: "", + trace: new(trace.Scheme), } for _, opt := range opts { if opt != nil { diff --git a/internal/scripting/client.go b/internal/scripting/client.go index 92b88b895..1835f299c 100644 --- a/internal/scripting/client.go +++ b/internal/scripting/client.go @@ -7,6 +7,7 @@ import ( "github.com/ydb-platform/ydb-go-genproto/Ydb_Scripting_V1" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Scripting" + "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Table" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_TableStats" "google.golang.org/grpc" @@ -86,8 +87,12 @@ func (c *Client) execute( c.config.OperationCancelAfter(), operation.ModeSync, ), + CollectStats: Ydb_Table.QueryStatsCollection_STATS_COLLECTION_UNSPECIFIED, + } + result = Ydb_Scripting.ExecuteYqlResult{ + ResultSets: nil, + QueryStats: nil, } - result = Ydb_Scripting.ExecuteYqlResult{} response *Ydb_Scripting.ExecuteYqlResponse ) defer func() { @@ -167,7 +172,10 @@ func (c *Client) explain( ), } response *Ydb_Scripting.ExplainYqlResponse - result = Ydb_Scripting.ExplainYqlResult{} + result = Ydb_Scripting.ExplainYqlResult{ + ParametersTypes: nil, + Plan: "", + } ) defer func() { onDone(e.Explanation.Plan, err) @@ -241,6 +249,7 @@ func (c *Client) streamExecute( c.config.OperationCancelAfter(), operation.ModeSync, ), + CollectStats: Ydb_Table.QueryStatsCollection_STATS_COLLECTION_UNSPECIFIED, } ) defer func() { diff --git a/internal/scripting/config/config.go b/internal/scripting/config/config.go index 35f90651d..010161412 100644 --- a/internal/scripting/config/config.go +++ b/internal/scripting/config/config.go @@ -34,7 +34,8 @@ func With(config config.Common) Option { func New(opts ...Option) Config { c := Config{ - trace: &trace.Scripting{}, + Common: config.Common{}, + trace: new(trace.Scripting), } for _, opt := range opts { if opt != nil { diff --git a/internal/stack/record.go b/internal/stack/record.go index 17c156736..d677dbf50 100644 --- a/internal/stack/record.go +++ b/internal/stack/record.go @@ -71,7 +71,7 @@ func PackagePath(b bool) recordOption { } } -var _ Caller = call{} +var _ Caller = call{function: 0, file: "", line: 0} type call struct { function uintptr diff --git a/internal/table/client.go b/internal/table/client.go index 4965b8b6f..608f616fb 100644 --- a/internal/table/client.go +++ b/internal/table/client.go @@ -54,15 +54,17 @@ func newClient( config *config.Config, ) *Client { c := &Client{ - clock: config.Clock(), - config: config, - cc: balancer, - nodeChecker: balancer, - build: builder, - index: make(map[*session]sessionInfo), - idle: list.New(), - waitQ: list.New(), - limit: config.SizeLimit(), + clock: config.Clock(), + config: config, + cc: balancer, + nodeChecker: balancer, + build: builder, + mu: xsync.Mutex{Mutex: sync.Mutex{}}, + index: make(map[*session]sessionInfo), + createInProgress: 0, + idle: list.New(), + waitQ: list.New(), + limit: config.SizeLimit(), waitChPool: sync.Pool{ New: func() interface{} { ch := make(chan *session) @@ -70,7 +72,9 @@ func newClient( return &ch }, }, - done: make(chan struct{}), + testHookGetWaitCh: nil, + wg: sync.WaitGroup{}, + done: make(chan struct{}), } if idleThreshold := config.IdleThreshold(); idleThreshold > 0 { c.wg.Add(1) @@ -123,7 +127,7 @@ func withCreateSessionOnClose(onClose func(s *session)) createSessionOption { } func (c *Client) createSession(ctx context.Context, opts ...createSessionOption) (s *session, err error) { - options := createSessionOptions{} + options := createSessionOptions{onCreate: nil, onClose: nil} for _, opt := range opts { if opt != nil { opt(&options) @@ -320,6 +324,7 @@ func (c *Client) internalPoolCreateSession(ctx context.Context) (s *session, err withCreateSessionOnCreate(func(s *session) { c.mu.WithLock(func() { c.index[s] = sessionInfo{ + idle: nil, touched: c.clock.Now(), } trace.TableOnPoolSessionAdd(c.config.Trace(), s) diff --git a/internal/table/config/config.go b/internal/table/config/config.go index 7c03b33e8..17909b371 100644 --- a/internal/table/config/config.go +++ b/internal/table/config/config.go @@ -253,11 +253,13 @@ func (c *Config) DeleteTimeout() time.Duration { func defaults() *Config { return &Config{ + Common: config.Common{}, sizeLimit: DefaultSessionPoolSizeLimit, createSessionTimeout: DefaultSessionPoolCreateSessionTimeout, deleteTimeout: DefaultSessionPoolDeleteTimeout, idleThreshold: DefaultSessionPoolIdleThreshold, clock: clockwork.NewRealClock(), - trace: &trace.Table{}, + ignoreTruncated: false, + trace: new(trace.Table), } } diff --git a/internal/table/retry.go b/internal/table/retry.go index e2b522b45..9f39a4a81 100644 --- a/internal/table/retry.go +++ b/internal/table/retry.go @@ -93,10 +93,13 @@ func retryBackoff( func (c *Client) retryOptions(opts ...table.Option) *table.Options { options := &table.Options{ - Trace: c.config.Trace(), + Label: "", + Idempotent: false, + Trace: c.config.Trace(), TxSettings: table.TxSettings( table.WithSerializableReadWrite(), ), + TxCommitOptions: nil, RetryOptions: []retry.Option{ retry.WithTrace(c.config.TraceRetry()), retry.WithBudget(c.config.RetryBudget()), @@ -108,7 +111,7 @@ func (c *Client) retryOptions(opts ...table.Option) *table.Options { } } if options.Trace == nil { - options.Trace = &trace.Table{} + options.Trace = new(trace.Table) } return options diff --git a/internal/table/scanner/result.go b/internal/table/scanner/result.go index fdebc2859..de2b91976 100644 --- a/internal/table/scanner/result.go +++ b/internal/table/scanner/result.go @@ -4,6 +4,7 @@ import ( "context" "errors" "io" + "sync" "sync/atomic" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" @@ -113,6 +114,25 @@ func NewStream( opts ...option, ) (StreamResult, error) { r := &streamResult{ + baseResult: baseResult{ + valueScanner: valueScanner{ + set: nil, + row: nil, + converter: nil, + stack: scanStack{v: nil, p: 0, scanItem: item{name: "", i: 0, t: nil, v: nil}}, + nextRow: 0, + nextItem: 0, + ignoreTruncated: false, + markTruncatedAsRetryable: false, + columnIndexes: nil, + errMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + err: nil, + }, + nextResultSetCounter: atomic.Uint64{}, + statsMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + stats: nil, + closed: atomic.Bool{}, + }, recv: recv, close: onClose, } @@ -131,9 +151,26 @@ func NewStream( func NewUnary(sets []*Ydb.ResultSet, stats *Ydb_TableStats.QueryStats, opts ...option) UnaryResult { r := &unaryResult{ baseResult: baseResult{ - stats: stats, + valueScanner: valueScanner{ + set: nil, + row: nil, + converter: nil, + stack: scanStack{v: nil, p: 0, scanItem: item{name: "", i: 0, t: nil, v: nil}}, + nextRow: 0, + nextItem: 0, + ignoreTruncated: false, + markTruncatedAsRetryable: false, + columnIndexes: nil, + errMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + err: nil, + }, + nextResultSetCounter: atomic.Uint64{}, + statsMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + stats: stats, + closed: atomic.Bool{}, }, - sets: sets, + sets: sets, + nextSet: 0, } for _, opt := range opts { if opt != nil { diff --git a/internal/table/scanner/scan_raw.go b/internal/table/scanner/scan_raw.go index dd3b81029..301a0f4ed 100644 --- a/internal/table/scanner/scan_raw.go +++ b/internal/table/scanner/scan_raw.go @@ -345,9 +345,10 @@ func (s *rawConverter) ListItem(i int) { } if t := s.assertTypeList(p.t); t != nil { s.stack.set(item{ - i: i, - t: t.ListType.GetItem(), - v: p.v.GetItems()[i], + name: "", + i: i, + t: t.ListType.GetItem(), + v: p.v.GetItems()[i], }) } } @@ -384,9 +385,10 @@ func (s *rawConverter) TupleItem(i int) { } if t := s.assertTypeTuple(p.t); t != nil { s.stack.set(item{ - i: i, - t: t.TupleType.GetElements()[i], - v: p.v.GetItems()[i], + name: "", + i: i, + t: t.TupleType.GetElements()[i], + v: p.v.GetItems()[i], }) } } @@ -467,9 +469,10 @@ func (s *rawConverter) DictKey(i int) { } if t := s.assertTypeDict(p.t); t != nil { s.stack.set(item{ - i: i, - t: t.DictType.GetKey(), - v: p.v.GetPairs()[i].GetKey(), + name: "", + i: i, + t: t.DictType.GetKey(), + v: p.v.GetPairs()[i].GetKey(), }) } } @@ -484,9 +487,10 @@ func (s *rawConverter) DictPayload(i int) { } if t := s.assertTypeDict(p.t); t != nil { s.stack.set(item{ - i: i, - t: t.DictType.GetPayload(), - v: p.v.GetPairs()[i].GetPayload(), + name: "", + i: i, + t: t.DictType.GetPayload(), + v: p.v.GetPairs()[i].GetPayload(), }) } } @@ -542,6 +546,7 @@ func (s *rawConverter) Unwrap() { s.stack.enter() s.stack.set(item{ name: "*", + i: 0, t: t.OptionalType.GetItem(), v: v, }) @@ -561,12 +566,20 @@ func (s *rawConverter) Decimal(t types.Type) (v [16]byte) { func (s *rawConverter) UnwrapDecimal() decimal.Decimal { if s.Err() != nil { - return decimal.Decimal{} + return decimal.Decimal{ + Bytes: [16]byte{}, + Precision: 0, + Scale: 0, + } } s.unwrap() d := s.assertTypeDecimal(s.stack.current().t) if d == nil { - return decimal.Decimal{} + return decimal.Decimal{ + Bytes: [16]byte{}, + Precision: 0, + Scale: 0, + } } return decimal.Decimal{ diff --git a/internal/table/scanner/scanner.go b/internal/table/scanner/scanner.go index ff611a8bd..7ea7911e2 100644 --- a/internal/table/scanner/scanner.go +++ b/internal/table/scanner/scanner.go @@ -56,8 +56,9 @@ func (s *valueScanner) Columns(it func(options.Column)) { } for _, m := range s.set.GetColumns() { it(options.Column{ - Name: m.GetName(), - Type: internalTypes.TypeFromYDB(m.GetType()), + Name: m.GetName(), + Type: internalTypes.TypeFromYDB(m.GetType()), + Family: "", }) } } @@ -511,12 +512,20 @@ func (s *valueScanner) unwrapValue() (v *Ydb.Value) { func (s *valueScanner) unwrapDecimal() decimal.Decimal { if s.Err() != nil { - return decimal.Decimal{} + return decimal.Decimal{ + Bytes: [16]byte{}, + Precision: 0, + Scale: 0, + } } s.unwrap() d := s.assertTypeDecimal(s.stack.current().t) if d == nil { - return decimal.Decimal{} + return decimal.Decimal{ + Bytes: [16]byte{}, + Precision: 0, + Scale: 0, + } } return decimal.Decimal{ @@ -1132,7 +1141,11 @@ func (s *valueScanner) setDefaultValue(dst interface{}) { case *value.Value: *v = s.value() case *decimal.Decimal: - *v = decimal.Decimal{} + *v = decimal.Decimal{ + Bytes: [16]byte{}, + Precision: 0, + Scale: 0, + } case sql.Scanner: err := v.Scan(nil) if err != nil { diff --git a/internal/table/scanner/stats.go b/internal/table/scanner/stats.go index d9772e34c..a4f583022 100644 --- a/internal/table/scanner/stats.go +++ b/internal/table/scanner/stats.go @@ -116,7 +116,10 @@ func (q *queryPhase) IsLiteralPhase() bool { func initOperationStats(x *Ydb_TableStats.OperationStats) stats.OperationStats { if x == nil { - return stats.OperationStats{} + return stats.OperationStats{ + Rows: 0, + Bytes: 0, + } } return stats.OperationStats{ diff --git a/internal/table/session.go b/internal/table/session.go index 98e8ce4db..9e1675f2d 100644 --- a/internal/table/session.go +++ b/internal/table/session.go @@ -145,14 +145,7 @@ func newSession(ctx context.Context, cc grpc.ClientConnInterface, config *config return nil, xerrors.WithStackTrace(err) } - s = &session{ - id: result.GetSessionId(), - config: config, - status: table.SessionReady, - } - s.lastUsage.Store(time.Now().Unix()) - - s.tableService = Ydb_Table_V1.NewTableServiceClient( + tableService := Ydb_Table_V1.NewTableServiceClient( conn.WithBeforeFunc( conn.WithContextModifier(cc, func(ctx context.Context) context.Context { return meta.WithTrailerCallback(balancerContext.WithEndpoint(ctx, s), s.checkCloseHint) @@ -163,6 +156,19 @@ func newSession(ctx context.Context, cc grpc.ClientConnInterface, config *config ), ) + s = &session{ + onClose: nil, + id: result.GetSessionId(), + tableService: tableService, + config: config, + status: table.SessionReady, + lastUsage: atomic.Int64{}, + statusMtx: sync.RWMutex{}, + closeOnce: sync.Once{}, + nodeID: atomic.Uint32{}, + } + s.lastUsage.Store(time.Now().Unix()) + return s, nil } @@ -279,14 +285,28 @@ func (s *session) CreateTable( ) (err error) { var ( request = Ydb_Table.CreateTableRequest{ - SessionId: s.id, - Path: path, + SessionId: s.id, + Path: path, + Columns: nil, + PrimaryKey: nil, + Profile: nil, OperationParams: operation.Params( ctx, s.config.OperationTimeout(), s.config.OperationCancelAfter(), operation.ModeSync, ), + Indexes: nil, + TtlSettings: nil, + StorageSettings: nil, + ColumnFamilies: nil, + Attributes: nil, + CompactionPolicy: "", + Partitions: nil, + PartitioningSettings: nil, + KeyBloomFilter: Ydb.FeatureFlag_STATUS_UNSPECIFIED, + ReadReplicasSettings: nil, + Tiering: "", } a = allocator.New() ) @@ -323,6 +343,9 @@ func (s *session) DescribeTable( s.config.OperationCancelAfter(), operation.ModeSync, ), + IncludeShardKeyBounds: false, + IncludeTableStats: false, + IncludePartitionStats: false, } for _, opt := range opts { if opt != nil { @@ -500,14 +523,32 @@ func (s *session) AlterTable( ) (err error) { var ( request = Ydb_Table.AlterTableRequest{ - SessionId: s.id, - Path: path, + SessionId: s.id, + Path: path, + AddColumns: nil, + DropColumns: nil, OperationParams: operation.Params( ctx, s.config.OperationTimeout(), s.config.OperationCancelAfter(), operation.ModeSync, ), + AlterColumns: nil, + TtlAction: nil, + AddIndexes: nil, + DropIndexes: nil, + AlterStorageSettings: nil, + AddColumnFamilies: nil, + AlterColumnFamilies: nil, + AlterAttributes: nil, + SetCompactionPolicy: "", + AlterPartitioningSettings: nil, + SetKeyBloomFilter: Ydb.FeatureFlag_STATUS_UNSPECIFIED, + SetReadReplicasSettings: nil, + AddChangefeeds: nil, + DropChangefeeds: nil, + RenameIndexes: nil, + TieringAction: nil, } a = allocator.New() ) @@ -572,6 +613,7 @@ func copyTables( operationCancelAfter, operation.ModeSync, ), + Tables: nil, } for _, opt := range opts { if opt != nil { @@ -622,6 +664,7 @@ func renameTables( operationCancelAfter, operation.ModeSync, ), + Tables: nil, } for _, opt := range opts { if opt != nil { @@ -823,8 +866,10 @@ func (s *session) executeQueryResult( table.Transaction, result.Result, error, ) { tx := &transaction{ - id: res.GetTxMeta().GetId(), - s: s, + id: res.GetTxMeta().GetId(), + s: s, + control: nil, + state: txState{rawVal: atomic.Uint32{}}, } if txControl.GetCommitTx() { tx.state.Store(txStateCommitted) @@ -1041,8 +1086,15 @@ func (s *session) StreamReadTable( s, ) request = Ydb_Table.ReadTableRequest{ - SessionId: s.id, - Path: path, + SessionId: s.id, + Path: path, + KeyRange: nil, + Columns: nil, + Ordered: false, + RowLimit: 0, + UseSnapshot: Ydb.FeatureFlag_STATUS_UNSPECIFIED, + BatchLimitBytes: 0, + BatchLimitRows: 0, } stream Ydb_Table_V1.TableService_StreamReadTableClient a = allocator.New() @@ -1109,6 +1161,7 @@ func (s *session) ReadRows( SessionId: s.id, Path: path, Keys: value.ToYDB(keys, a), + Columns: nil, } response *Ydb_Table.ReadRowsResponse ) @@ -1160,9 +1213,10 @@ func (s *session) StreamExecuteScanQuery( s, q, parameters, ) request = Ydb_Table.ExecuteScanQueryRequest{ - Query: q.toYDB(a), - Parameters: parameters.ToYDB(a), - Mode: Ydb_Table.ExecuteScanQueryRequest_MODE_EXEC, // set default + Query: q.toYDB(a), + Parameters: parameters.ToYDB(a), + Mode: Ydb_Table.ExecuteScanQueryRequest_MODE_EXEC, // set default + CollectStats: Ydb_Table.QueryStatsCollection_STATS_COLLECTION_UNSPECIFIED, } stream Ydb_Table_V1.TableService_StreamExecuteScanQueryClient callOptions []grpc.CallOption @@ -1252,6 +1306,8 @@ func (s *session) BulkUpsert(ctx context.Context, table string, rows value.Value s.config.OperationCancelAfter(), operation.ModeSync, ), + DataFormat: nil, + Data: nil, }, callOptions..., ) @@ -1304,6 +1360,7 @@ func (s *session) BeginTransaction( id: result.GetTxMeta().GetId(), s: s, control: table.TxControl(table.WithTxID(result.GetTxMeta().GetId())), + state: txState{rawVal: atomic.Uint32{}}, } tx.state.Store(txStateInitialized) diff --git a/internal/table/transaction.go b/internal/table/transaction.go index 3289d45cc..2ba0ccb11 100644 --- a/internal/table/transaction.go +++ b/internal/table/transaction.go @@ -161,6 +161,7 @@ func (tx *transaction) CommitTx( tx.s.config.OperationCancelAfter(), operation.ModeSync, ), + CollectStats: Ydb_Table.QueryStatsCollection_STATS_COLLECTION_UNSPECIFIED, } response *Ydb_Table.CommitTransactionResponse result = new(Ydb_Table.CommitTransactionResult) diff --git a/internal/table/ttl.go b/internal/table/ttl.go index fd3ad945e..45baf260e 100644 --- a/internal/table/ttl.go +++ b/internal/table/ttl.go @@ -16,6 +16,7 @@ func NewTimeToLiveSettings(settings *Ydb_Table.TtlSettings) *options.TimeToLiveS ColumnName: mode.DateTypeColumn.GetColumnName(), ExpireAfterSeconds: mode.DateTypeColumn.GetExpireAfterSeconds(), Mode: options.TimeToLiveModeDateType, + ColumnUnit: nil, } case *Ydb_Table.TtlSettings_ValueSinceUnixEpoch: diff --git a/internal/topic/topicclientinternal/client.go b/internal/topic/topicclientinternal/client.go index 87bf774e4..913116bc6 100644 --- a/internal/topic/topicclientinternal/client.go +++ b/internal/topic/topicclientinternal/client.go @@ -2,11 +2,14 @@ package topicclientinternal import ( "context" + "time" "github.com/ydb-platform/ydb-go-genproto/Ydb_Topic_V1" "google.golang.org/grpc" "github.com/ydb-platform/ydb-go-sdk/v3/credentials" + "github.com/ydb-platform/ydb-go-sdk/v3/internal/config" + "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawoptional" "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic" "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawydb" "github.com/ydb-platform/ydb-go-sdk/v3/internal/topic" @@ -50,7 +53,8 @@ func New( func newTopicConfig(opts ...topicoptions.TopicOption) topic.Config { c := topic.Config{ - Trace: &trace.Topic{}, + Common: config.Common{}, + Trace: new(trace.Topic), } for _, opt := range opts { if opt != nil { @@ -68,7 +72,7 @@ func (c *Client) Close(_ context.Context) error { // Alter topic options func (c *Client) Alter(ctx context.Context, path string, opts ...topicoptions.AlterOption) error { - req := &rawtopic.AlterTopicRequest{} + req := new(rawtopic.AlterTopicRequest) req.OperationParams = c.defaultOperationParams req.Path = path for _, opt := range opts { @@ -100,7 +104,7 @@ func (c *Client) Create( path string, opts ...topicoptions.CreateOption, ) error { - req := &rawtopic.CreateTopicRequest{} + req := new(rawtopic.CreateTopicRequest) req.OperationParams = c.defaultOperationParams req.Path = path @@ -175,7 +179,14 @@ func (c *Client) Describe( // Drop topic func (c *Client) Drop(ctx context.Context, path string, opts ...topicoptions.DropOption) error { - req := rawtopic.DropTopicRequest{} + req := rawtopic.DropTopicRequest{ + OperationParams: rawydb.OperationParams{ + OperationMode: rawydb.OperationParamsModeUnspecified, + OperationTimeout: rawoptional.Duration{Value: time.Duration(0), HasValue: false}, + CancelAfter: rawoptional.Duration{Value: time.Duration(0), HasValue: false}, + }, + Path: "", + } req.OperationParams = c.defaultOperationParams req.Path = path diff --git a/internal/topic/topicreaderinternal/batch.go b/internal/topic/topicreaderinternal/batch.go index e8e00ad01..73d99eb64 100644 --- a/internal/topic/topicreaderinternal/batch.go +++ b/internal/topic/topicreaderinternal/batch.go @@ -45,7 +45,9 @@ func newBatch(session *partitionSession, messages []*PublicMessage) (*PublicBatc } offset := commitRange{ - partitionSession: session, + commitOffsetStart: rawtopicreader.Offset(0), + commitOffsetEnd: rawtopicreader.Offset(0), + partitionSession: session, } if len(messages) > 0 { offset.commitOffsetStart = messages[0].commitRange.commitOffsetStart @@ -55,6 +57,7 @@ func newBatch(session *partitionSession, messages []*PublicMessage) (*PublicBatc return &PublicBatch{ Messages: messages, commitRange: offset, + DoNotCopy: empty.DoNotCopy{}, }, nil } @@ -68,7 +71,7 @@ func newBatchFromStream( for i := range sb.MessageData { sMess := &sb.MessageData[i] - dstMess := &PublicMessage{} + dstMess := new(PublicMessage) messages[i] = dstMess dstMess.CreatedAt = sMess.CreatedAt dstMess.MessageGroupID = sMess.MessageGroupID @@ -128,7 +131,7 @@ func (m *PublicBatch) getCommitRange() PublicCommitRange { func (m *PublicBatch) append(b *PublicBatch) (*PublicBatch, error) { var res *PublicBatch if m == nil { - res = &PublicBatch{} + res = new(PublicBatch) } else { res = m } diff --git a/internal/topic/topicreaderinternal/batcher.go b/internal/topic/topicreaderinternal/batcher.go index 8eaa5eb6b..fd853b06b 100644 --- a/internal/topic/topicreaderinternal/batcher.go +++ b/internal/topic/topicreaderinternal/batcher.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "sync" "sync/atomic" "github.com/ydb-platform/ydb-go-sdk/v3/internal/empty" @@ -29,9 +30,16 @@ type batcher struct { func newBatcher() *batcher { return &batcher{ - messages: make(batcherMessagesMap), - closeChan: make(empty.Chan), + popInFlight: 0, + closeErr: nil, hasNewMessages: make(empty.Chan, 1), + + m: xsync.Mutex{Mutex: sync.Mutex{}}, + + forceIgnoreMinRestrictionsOnNextMessagesBatch: false, + closed: false, + closeChan: make(empty.Chan), + messages: make(batcherMessagesMap), } } @@ -108,7 +116,7 @@ func (o batcherGetOptions) cutBatchItemsHead(items batcherMessageOrderItems) ( ok bool, ) { notFound := func() (batcherMessageOrderItem, batcherMessageOrderItems, bool) { - return batcherMessageOrderItem{}, batcherMessageOrderItems{}, false + return batcherMessageOrderItem{Batch: nil, RawMessage: nil}, batcherMessageOrderItems{}, false } if len(items) == 0 { return notFound() @@ -231,19 +239,26 @@ func newBatcherResultCandidate( ok bool, ) batcherResultCandidate { return batcherResultCandidate{ - Key: key, - Result: result, - Rest: rest, - Ok: ok, + Key: key, + Result: result, + Rest: rest, + Ok: ok, + WaiterIndex: 0, } } func (b *batcher) findNeedLock(filter batcherGetOptions) batcherResultCandidate { if len(b.messages) == 0 { - return batcherResultCandidate{} + return batcherResultCandidate{ + Key: nil, + Result: batcherMessageOrderItem{Batch: nil, RawMessage: nil}, + Rest: batcherMessageOrderItems{}, + Ok: false, + WaiterIndex: 0, + } } - rawMessageOpts := batcherGetOptions{rawMessagesOnly: true} + rawMessageOpts := batcherGetOptions{MinCount: 0, MaxCount: 0, rawMessagesOnly: true} var batchResult batcherResultCandidate needBatchResult := true @@ -344,11 +359,11 @@ type batcherMessageOrderItem struct { } func newBatcherItemBatch(b *PublicBatch) batcherMessageOrderItem { - return batcherMessageOrderItem{Batch: b} + return batcherMessageOrderItem{Batch: b, RawMessage: nil} } func newBatcherItemRawMessage(b rawtopicreader.ServerMessage) batcherMessageOrderItem { - return batcherMessageOrderItem{RawMessage: b} + return batcherMessageOrderItem{Batch: nil, RawMessage: b} } func (item *batcherMessageOrderItem) IsBatch() bool { diff --git a/internal/topic/topicreaderinternal/commit_range.go b/internal/topic/topicreaderinternal/commit_range.go index 18d00b0d8..006a485a2 100644 --- a/internal/topic/topicreaderinternal/commit_range.go +++ b/internal/topic/topicreaderinternal/commit_range.go @@ -41,7 +41,7 @@ func NewCommitRangesWithCapacity(capacity int) CommitRanges { } func NewCommitRangesFromPublicCommits(ranges []PublicCommitRange) CommitRanges { - res := CommitRanges{} + res := CommitRanges{ranges: nil} res.ranges = make([]commitRange, len(ranges)) for i := 0; i < len(res.ranges); i++ { res.ranges[i] = ranges[i].priv @@ -133,6 +133,7 @@ func (r *CommitRanges) toRawPartitionCommitOffset() []rawtopicreader.PartitionCo newPartition := func(id rawtopicreader.PartitionSessionID) rawtopicreader.PartitionCommitOffset { return rawtopicreader.PartitionCommitOffset{ PartitionSessionID: id, + Offsets: nil, } } diff --git a/internal/topic/topicreaderinternal/committer.go b/internal/topic/topicreaderinternal/committer.go index 67940df1d..d41fe9a8b 100644 --- a/internal/topic/topicreaderinternal/committer.go +++ b/internal/topic/topicreaderinternal/committer.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "sync" "sync/atomic" "time" @@ -55,11 +56,17 @@ type committer struct { func newCommitterStopped(tracer *trace.Topic, lifeContext context.Context, mode PublicCommitMode, send sendMessageToServerFunc, readerID int64) *committer { //nolint:lll,revive res := &committer{ - mode: mode, - clock: clockwork.NewRealClock(), - send: send, - backgroundWorker: *background.NewWorker(lifeContext, fmt.Sprintf("ydb-topic-reader-committer: %v", readerID)), - tracer: tracer, + BufferTimeLagTrigger: time.Duration(0), + BufferCountTrigger: 0, + send: send, + mode: mode, + clock: clockwork.NewRealClock(), + commitLoopSignal: nil, + backgroundWorker: *background.NewWorker(lifeContext, fmt.Sprintf("ydb-topic-reader-committer: %v", readerID)), + tracer: tracer, + m: xsync.Mutex{Mutex: sync.Mutex{}}, + waiters: nil, + commits: CommitRanges{ranges: nil}, } res.initChannels() diff --git a/internal/topic/topicreaderinternal/grpc_synced_stream.go b/internal/topic/topicreaderinternal/grpc_synced_stream.go index 0a573ee57..b192de67f 100644 --- a/internal/topic/topicreaderinternal/grpc_synced_stream.go +++ b/internal/topic/topicreaderinternal/grpc_synced_stream.go @@ -6,7 +6,7 @@ import ( "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopicreader" ) -var _ RawTopicReaderStream = &syncedStream{} +var _ RawTopicReaderStream = &syncedStream{m: sync.Mutex{}, stream: nil} type syncedStream struct { m sync.Mutex diff --git a/internal/topic/topicreaderinternal/message.go b/internal/topic/topicreaderinternal/message.go index 13cc98f0c..6985ed623 100644 --- a/internal/topic/topicreaderinternal/message.go +++ b/internal/topic/topicreaderinternal/message.go @@ -9,6 +9,7 @@ import ( "github.com/ydb-platform/ydb-go-sdk/v3/internal/empty" "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopiccommon" + "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopicreader" "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" ) @@ -107,7 +108,7 @@ type PublicMessageBuilder struct { } func NewPublicMessageBuilder() *PublicMessageBuilder { - res := &PublicMessageBuilder{} + res := &PublicMessageBuilder{mess: nil} res.initMessage() return res @@ -115,15 +116,33 @@ func NewPublicMessageBuilder() *PublicMessageBuilder { func (pmb *PublicMessageBuilder) initMessage() { pmb.mess = &PublicMessage{ - commitRange: commitRange{partitionSession: newPartitionSession( - context.Background(), - "", - 0, - 0, - "", - 0, - 0, - )}, + DoNotCopy: empty.DoNotCopy{}, + SeqNo: 0, + CreatedAt: time.Time{}, + MessageGroupID: "", + WriteSessionMetadata: nil, + Offset: 0, + WrittenAt: time.Time{}, + ProducerID: "", + Metadata: nil, + commitRange: commitRange{ + commitOffsetStart: rawtopicreader.Offset(0), + commitOffsetEnd: rawtopicreader.Offset(0), + partitionSession: newPartitionSession( + context.Background(), + "", + 0, + 0, + "", + 0, + 0, + ), + }, + data: oneTimeReader{err: nil, reader: nil}, + rawDataLen: 0, + bufferBytesAccount: 0, + UncompressedSize: 0, + dataConsumed: false, } } @@ -189,7 +208,7 @@ func (pmb *PublicMessageBuilder) ProducerID(producerID string) *PublicMessageBui func (pmb *PublicMessageBuilder) DataAndUncompressedSize(data []byte) *PublicMessageBuilder { copyData := make([]byte, len(data)) copy(copyData, data) - pmb.mess.data = oneTimeReader{reader: bytes.NewReader(data)} + pmb.mess.data = oneTimeReader{err: nil, reader: bytes.NewReader(data)} pmb.mess.dataConsumed = false pmb.mess.rawDataLen = len(copyData) pmb.mess.UncompressedSize = len(copyData) diff --git a/internal/topic/topicreaderinternal/message_content_pool.go b/internal/topic/topicreaderinternal/message_content_pool.go index 73b561cae..fd3da1959 100644 --- a/internal/topic/topicreaderinternal/message_content_pool.go +++ b/internal/topic/topicreaderinternal/message_content_pool.go @@ -27,7 +27,7 @@ const ( maxInitialBufferSize = 1024 * 1024 * 50 // protection from bad UncompressedSize from stream ) -var globalReadMessagePool = &sync.Pool{} +var globalReadMessagePool = new(sync.Pool) func callbackOnReaderContent( p Pool, diff --git a/internal/topic/topicreaderinternal/one_time_reader.go b/internal/topic/topicreaderinternal/one_time_reader.go index 4a54d6f7a..3646b4d28 100644 --- a/internal/topic/topicreaderinternal/one_time_reader.go +++ b/internal/topic/topicreaderinternal/one_time_reader.go @@ -11,6 +11,7 @@ type oneTimeReader struct { func newOneTimeReader(reader io.Reader) oneTimeReader { return oneTimeReader{ + err: nil, reader: reader, } } diff --git a/internal/topic/topicreaderinternal/partition_session.go b/internal/topic/topicreaderinternal/partition_session.go index 781de1782..76b3e6e0b 100644 --- a/internal/topic/topicreaderinternal/partition_session.go +++ b/internal/topic/topicreaderinternal/partition_session.go @@ -44,13 +44,15 @@ func newPartitionSession( partitionContext, cancel := xcontext.WithCancel(partitionContext) res := &partitionSession{ - Topic: topic, - PartitionID: partitionID, - readerID: readerID, - connectionID: connectionID, - ctx: partitionContext, - ctxCancel: cancel, - partitionSessionID: partitionSessionID, + Topic: topic, + PartitionID: partitionID, + readerID: readerID, + connectionID: connectionID, + ctx: partitionContext, + ctxCancel: cancel, + partitionSessionID: partitionSessionID, + lastReceivedOffsetEndVal: atomic.Int64{}, + committedOffsetVal: atomic.Int64{}, } res.committedOffsetVal.Store(committedOffset.ToInt64()) res.lastReceivedOffsetEndVal.Store(committedOffset.ToInt64() - 1) @@ -114,7 +116,7 @@ func (c *partitionSessionStorage) Add(session *partitionSession) error { if _, ok := c.sessions[session.partitionSessionID]; ok { return xerrors.WithStackTrace(fmt.Errorf("session id already existed: %v", session.partitionSessionID)) } - c.sessions[session.partitionSessionID] = &sessionInfo{Session: session} + c.sessions[session.partitionSessionID] = &sessionInfo{Session: session, RemovedIndex: 0, RemoveTime: time.Time{}} return nil } diff --git a/internal/topic/topicreaderinternal/reader.go b/internal/topic/topicreaderinternal/reader.go index 85bd5ef5c..4a2bb2086 100644 --- a/internal/topic/topicreaderinternal/reader.go +++ b/internal/topic/topicreaderinternal/reader.go @@ -62,7 +62,7 @@ func (o ReadMessageBatchOptions) clone() ReadMessageBatchOptions { } func newReadMessageBatchOptions() ReadMessageBatchOptions { - return ReadMessageBatchOptions{} + return ReadMessageBatchOptions{batcherGetOptions: batcherGetOptions{MinCount: 0, MaxCount: 0, rawMessagesOnly: false}} } // PublicReadBatchOption для различных пожеланий к батчу вроде WithMaxMessages(int) diff --git a/internal/topic/topicreaderinternal/stream_reader_impl.go b/internal/topic/topicreaderinternal/stream_reader_impl.go index a974376ed..168d8e392 100644 --- a/internal/topic/topicreaderinternal/stream_reader_impl.go +++ b/internal/topic/topicreaderinternal/stream_reader_impl.go @@ -9,6 +9,7 @@ import ( "math/big" "reflect" "runtime/pprof" + "sync" "sync/atomic" "time" @@ -75,20 +76,26 @@ type topicStreamReaderConfig struct { func newTopicStreamReaderConfig() topicStreamReaderConfig { return topicStreamReaderConfig{ - BaseContext: context.Background(), - BufferSizeProtoBytes: defaultBufferSize, - Cred: credentials.NewAnonymousCredentials(), - CredUpdateInterval: time.Hour, - CommitMode: CommitModeAsync, - CommitterBatchTimeLag: time.Second, - Decoders: newDecoderMap(), - Trace: &trace.Topic{}, + CommitterBatchTimeLag: time.Second, + CommitterBatchCounterTrigger: 0, + BaseContext: context.Background(), + BufferSizeProtoBytes: defaultBufferSize, + Cred: credentials.NewAnonymousCredentials(), + CredUpdateInterval: time.Hour, + Consumer: "", + ReadWithoutConsumer: false, + ReadSelectors: nil, + Trace: new(trace.Topic), + GetPartitionStartOffsetCallback: nil, + CommitMode: CommitModeAsync, + Decoders: newDecoderMap(), } } func (cfg *topicStreamReaderConfig) initMessage() *rawtopicreader.InitRequest { res := &rawtopicreader.InitRequest{ - Consumer: cfg.Consumer, + Consumer: cfg.Consumer, + TopicsReadSettings: nil, } res.TopicsReadSettings = make([]rawtopicreader.TopicReadSettings, len(cfg.ReadSelectors)) @@ -148,19 +155,31 @@ func newTopicStreamReaderStopped( cfg: cfg, ctx: stopPump, freeBytes: make(chan int, 1), - stream: &syncedStream{stream: stream}, + stream: &syncedStream{m: sync.Mutex{}, stream: stream}, cancel: cancel, batcher: newBatcher(), readConnectionID: "preinitID-" + readerConnectionID.String(), readerID: readerID, rawMessagesFromBuffer: make(chan rawtopicreader.ServerMessage, 1), + restBufferSizeBytes: atomic.Int64{}, + sessionController: partitionSessionStorage{ + m: sync.RWMutex{}, + sessions: nil, + removeIndex: 0, + lastCompactedTime: time.Time{}, + lastCompactedRemoveIndex: 0, + }, + backgroundWorkers: *background.NewWorker(stopPump, fmt.Sprintf( + "topic-reader-stream-background: %v", + readerID, + )), + committer: nil, + m: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + err: nil, + started: false, + closed: false, } - res.backgroundWorkers = *background.NewWorker(stopPump, fmt.Sprintf( - "topic-reader-stream-background: %v", - res.readerID, - )) - res.committer = newCommitterStopped(cfg.Trace, labeledContext, cfg.CommitMode, res.send, res.readerID) res.committer.BufferTimeLagTrigger = cfg.CommitterBatchTimeLag res.committer.BufferCountTrigger = cfg.CommitterBatchCounterTrigger @@ -792,6 +811,8 @@ func (r *topicStreamReaderImpl) onStartPartitionSessionRequestFromBuffer( respMessage := &rawtopicreader.StartPartitionSessionResponse{ PartitionSessionID: session.partitionSessionID, + ReadOffset: rawtopicreader.OptionalOffset{Offset: rawtopicreader.Offset(0), HasValue: false}, + CommitOffset: rawtopicreader.OptionalOffset{Offset: rawtopicreader.Offset(0), HasValue: false}, } var forceOffset *int64 diff --git a/internal/topic/topicreaderinternal/stream_reconnector.go b/internal/topic/topicreaderinternal/stream_reconnector.go index 403c81f93..c0165a2ea 100644 --- a/internal/topic/topicreaderinternal/stream_reconnector.go +++ b/internal/topic/topicreaderinternal/stream_reconnector.go @@ -57,13 +57,24 @@ func newReaderReconnector( tracer *trace.Topic, ) *readerReconnector { res := &readerReconnector{ - readerID: readerID, - clock: clockwork.NewRealClock(), - readerConnect: connector, - streamErr: errUnconnected, - connectTimeout: connectTimeout, - tracer: tracer, - retrySettings: retrySettings, + background: background.Worker{}, + clock: clockwork.NewRealClock(), + retrySettings: retrySettings, + streamVal: nil, + streamContextCancel: nil, + streamErr: errUnconnected, + closedErr: nil, + initErr: nil, + tracer: tracer, + readerConnect: connector, + reconnectFromBadStream: nil, + connectTimeout: connectTimeout, + readerID: readerID, + streamConnectionInProgress: nil, + initDoneCh: nil, + m: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + closeOnce: sync.Once{}, + initDone: false, } if res.connectTimeout == 0 { diff --git a/internal/topic/topicwriterinternal/encoders.go b/internal/topic/topicwriterinternal/encoders.go index a1ca73ad9..4347607b2 100644 --- a/internal/topic/topicwriterinternal/encoders.go +++ b/internal/topic/topicwriterinternal/encoders.go @@ -104,6 +104,9 @@ func NewEncoderSelector( tracer: tracer, writerReconnectorID: writerReconnectorID, sessionID: sessionID, + allowedCodecs: rawtopiccommon.SupportedCodecs{}, + lastSelectedCodec: 0, + batchCounter: 0, } res.ResetAllowedCodecs(allowedCodecs) diff --git a/internal/topic/topicwriterinternal/message.go b/internal/topic/topicwriterinternal/message.go index 5c618e631..24956ec5e 100644 --- a/internal/topic/topicwriterinternal/message.go +++ b/internal/topic/topicwriterinternal/message.go @@ -44,11 +44,14 @@ func (p PublicFuturePartitioning) ToRaw() rawtopicwriter.Partitioning { func NewPartitioningWithMessageGroupID(id string) PublicFuturePartitioning { return PublicFuturePartitioning{ messageGroupID: id, + partitionID: 0, + hasPartitionID: false, } } func NewPartitioningWithPartitionID(id int64) PublicFuturePartitioning { return PublicFuturePartitioning{ + messageGroupID: "", partitionID: id, hasPartitionID: true, } @@ -219,7 +222,15 @@ func newMessageDataWithContent( encoders *EncoderMap, ) messageWithDataContent { return messageWithDataContent{ - PublicMessage: message, - encoders: encoders, + PublicMessage: message, + encoders: encoders, + dataWasRead: false, + hasRawContent: false, + hasEncodedContent: false, + metadataCached: false, + bufCodec: 0, + bufEncoded: bytes.Buffer{}, + rawBuf: bytes.Buffer{}, + BufUncompressedSize: 0, } } diff --git a/internal/topic/topicwriterinternal/queue.go b/internal/topic/topicwriterinternal/queue.go index a834f7071..69f872f46 100644 --- a/internal/topic/topicwriterinternal/queue.go +++ b/internal/topic/topicwriterinternal/queue.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "sort" + "sync" "github.com/ydb-platform/ydb-go-sdk/v3/internal/empty" "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopicwriter" @@ -50,11 +51,19 @@ type messageQueue struct { func newMessageQueue() messageQueue { return messageQueue{ - messagesByOrder: make(map[int]messageWithDataContent), - seqNoToOrderID: make(map[int64]int), - hasNewMessages: make(empty.Chan, 1), - closedChan: make(empty.Chan), - lastSeqNo: -1, + messagesByOrder: make(map[int]messageWithDataContent), + seqNoToOrderID: make(map[int64]int), + hasNewMessages: make(empty.Chan, 1), + closedChan: make(empty.Chan), + lastSeqNo: -1, + OnAckReceived: nil, + closedErr: nil, + acksReceivedEvent: xsync.EventBroadcast{}, + m: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + stopReceiveMessagesReason: nil, + closed: false, + lastWrittenIndex: 0, + lastSentIndex: 0, } } diff --git a/internal/topic/topicwriterinternal/writer_reconnector.go b/internal/topic/topicwriterinternal/writer_reconnector.go index 88738c83b..75b63545c 100644 --- a/internal/topic/topicwriterinternal/writer_reconnector.go +++ b/internal/topic/topicwriterinternal/writer_reconnector.go @@ -8,6 +8,7 @@ import ( "math" "math/big" "runtime" + "sync" "sync/atomic" "time" @@ -80,7 +81,16 @@ func newWriterReconnectorConfig(options ...PublicWriterOption) WriterReconnector credUpdateInterval: time.Hour, clock: clockwork.NewRealClock(), compressorCount: runtime.NumCPU(), - tracer: &trace.Topic{}, + tracer: new(trace.Topic), + producerID: "", + topic: "", + writerMeta: nil, + defaultPartitioning: rawtopicwriter.Partitioning{ + Type: rawtopicwriter.PartitioningUndefined, + MessageGroupID: "", + PartitionID: 0, + }, + forceCodec: rawtopiccommon.CodecUNSPECIFIED, }, AutoSetSeqNo: true, AutoSetCreatedTime: true, @@ -88,7 +98,14 @@ func newWriterReconnectorConfig(options ...PublicWriterOption) WriterReconnector MaxQueueLen: 1000, //nolint:gomnd RetrySettings: topic.RetrySettings{ StartTimeout: topic.DefaultStartTimeout, + CheckError: nil, }, + Common: config.Common{}, + AdditionalEncoders: nil, + Connect: nil, + WaitServerAck: false, + OnWriterInitResponseCallback: nil, + connectTimeout: time.Duration(0), } if cfg.compressorCount == 0 { cfg.compressorCount = 1 @@ -153,6 +170,13 @@ func newWriterReconnectorStopped( encodersMap: NewEncoderMap(), writerInstanceID: writerInstanceID.String(), retrySettings: cfg.RetrySettings, + background: background.Worker{}, + sessionID: "", + initDoneCh: nil, + initInfo: InitialInfo{LastSeqNum: 0}, + m: xsync.RWMutex{RWMutex: sync.RWMutex{}}, + firstConnectionHandled: atomic.Bool{}, + initDone: false, } res.queue.OnAckReceived = res.onAckReceived @@ -555,6 +579,7 @@ func (w *WriterReconnector) onWriterInitCallbackHandler(writerStream *SingleStre SessionID: w.sessionID, PartitionID: writerStream.PartitionID, CodecsFromServer: createPublicCodecsFromRaw(writerStream.CodecsFromServer), + AllowedCodecs: nil, } if err := w.cfg.OnWriterInitResponseCallback(info); err != nil { diff --git a/internal/topic/topicwriterinternal/writer_single_stream.go b/internal/topic/topicwriterinternal/writer_single_stream.go index 4643ad3dc..53edf2308 100644 --- a/internal/topic/topicwriterinternal/writer_single_stream.go +++ b/internal/topic/topicwriterinternal/writer_single_stream.go @@ -88,6 +88,25 @@ func newSingleStreamWriterStopped( cfg.reconnectorInstanceID, )), closeCompleted: make(empty.Chan), + Encoder: EncoderSelector{ + m: nil, + tracer: nil, + writerReconnectorID: "", + sessionID: "", + allowedCodecs: rawtopiccommon.SupportedCodecs{}, + lastSelectedCodec: 0, + parallelCompressors: 0, + batchCounter: 0, + measureIntervalBatches: 0, + }, + CodecsFromServer: rawtopiccommon.SupportedCodecs{}, + allowedCodecs: rawtopiccommon.SupportedCodecs{}, + SessionID: "", + closeReason: nil, + ReceivedLastSeqNum: 0, + PartitionID: 0, + closed: atomic.Bool{}, + LastSeqNumRequested: false, } } @@ -282,7 +301,7 @@ func (w *SingleStreamWriter) sendUpdateToken(ctx context.Context) (err error) { return nil } - req := &rawtopicwriter.UpdateTokenRequest{} + req := new(rawtopicwriter.UpdateTokenRequest) req.Token = token return stream.Send(req) diff --git a/internal/types/types.go b/internal/types/types.go index 00a77db71..92972d798 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" + "google.golang.org/protobuf/types/known/structpb" "github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator" "github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring" @@ -488,7 +489,9 @@ func (v PgType) ToYDB(a *allocator.Allocator) *Ydb.Type { // TODO: make allocator return &Ydb.Type{Type: &Ydb.Type_PgType{ PgType: &Ydb.PgType{ - Oid: v.OID, + Oid: v.OID, + Typlen: 0, + Typmod: 0, }, }} } @@ -913,7 +916,9 @@ func (v Void) Yql() string { } var _voidType = &Ydb.Type{ - Type: &Ydb.Type_VoidType{}, + Type: &Ydb.Type_VoidType{ + VoidType: structpb.NullValue_NULL_VALUE, + }, } func (v Void) equalsTo(rhs Type) bool { @@ -941,7 +946,9 @@ func (v Null) Yql() string { } var _nullType = &Ydb.Type{ - Type: &Ydb.Type_NullType{}, + Type: &Ydb.Type_NullType{ + NullType: structpb.NullValue_NULL_VALUE, + }, } func (v Null) equalsTo(rhs Type) bool { diff --git a/internal/value/value.go b/internal/value/value.go index 095f56174..f1c7a79cf 100644 --- a/internal/value/value.go +++ b/internal/value/value.go @@ -1282,6 +1282,10 @@ func (v pgValue) toYDB(_ *allocator.Allocator) *Ydb.Value { Value: &Ydb.Value_TextValue{ TextValue: v.val, }, + Items: nil, + Pairs: nil, + VariantIndex: 0, + High_128: 0, } } @@ -2249,7 +2253,11 @@ func (v voidValue) Yql() string { var ( _voidValueType = types.Void{} _voidValue = &Ydb.Value{ - Value: new(Ydb.Value_NullFlagValue), + Value: new(Ydb.Value_NullFlagValue), + Items: nil, + Pairs: nil, + VariantIndex: 0, + High_128: 0, } ) @@ -2405,19 +2413,23 @@ func ZeroValue(t types.Type) Value { case *types.List, *types.EmptyList: return &listValue{ - t: t, + t: t, + items: nil, } case *types.Set: return &setValue{ - t: t, + t: t, + items: nil, } case *types.Dict: return &dictValue{ - t: t.ValueType(), + t: t.ValueType(), + values: nil, } case *types.EmptyDict: return &dictValue{ - t: t, + t: t, + values: nil, } case *types.Tuple: return TupleValue(func() []Value { diff --git a/internal/xcontext/cancels_quard.go b/internal/xcontext/cancels_quard.go index b2743e656..e9514b99d 100644 --- a/internal/xcontext/cancels_quard.go +++ b/internal/xcontext/cancels_quard.go @@ -14,6 +14,7 @@ type ( func NewCancelsGuard() *CancelsGuard { return &CancelsGuard{ + mu: sync.Mutex{}, cancels: make(map[*context.CancelFunc]struct{}), } } diff --git a/internal/xcontext/context_with_cancel.go b/internal/xcontext/context_with_cancel.go index f8cc68923..e69140ac2 100644 --- a/internal/xcontext/context_with_cancel.go +++ b/internal/xcontext/context_with_cancel.go @@ -9,6 +9,10 @@ import ( func WithCancel(ctx context.Context) (context.Context, context.CancelFunc) { childCtx := &cancelCtx{ parentCtx: ctx, + ctx: nil, + ctxCancel: nil, + m: sync.Mutex{}, + err: nil, } childCtx.ctx, childCtx.ctxCancel = context.WithCancel(ctx) diff --git a/internal/xcontext/context_with_timeout.go b/internal/xcontext/context_with_timeout.go index b120fbd85..511d28644 100644 --- a/internal/xcontext/context_with_timeout.go +++ b/internal/xcontext/context_with_timeout.go @@ -12,7 +12,11 @@ import ( func WithTimeout(ctx context.Context, t time.Duration) (context.Context, context.CancelFunc) { childCtx := &timeoutCtx{ parentCtx: ctx, + ctx: nil, + ctxCancel: nil, from: stack.Record(1), + m: sync.Mutex{}, + err: nil, } childCtx.ctx, childCtx.ctxCancel = context.WithTimeout(ctx, t) diff --git a/internal/xerrors/issues.go b/internal/xerrors/issues.go index 066bb94eb..c52f04be4 100644 --- a/internal/xerrors/issues.go +++ b/internal/xerrors/issues.go @@ -59,6 +59,7 @@ func (ii issues) String() string { func NewWithIssues(text string, issues ...error) error { err := &withIssuesError{ reason: text, + issues: nil, } for i := range issues { if issues[i] != nil { diff --git a/internal/xerrors/operation.go b/internal/xerrors/operation.go index 7020e4f42..4e6073b12 100644 --- a/internal/xerrors/operation.go +++ b/internal/xerrors/operation.go @@ -84,8 +84,10 @@ func (e *operationOption) applyToOperationError(oe *operationError) { // FromOperation must use as `Operation(FromOperation(operation.Status))` func FromOperation(operation operation.Status) *operationOption { return &operationOption{ - code: operation.GetStatus(), - issues: operation.GetIssues(), + code: operation.GetStatus(), + issues: operation.GetIssues(), + address: "", + traceID: "", } } @@ -95,7 +97,10 @@ type oeOpt interface { func Operation(opts ...oeOpt) error { oe := &operationError{ - code: Ydb.StatusIds_STATUS_CODE_UNSPECIFIED, + code: Ydb.StatusIds_STATUS_CODE_UNSPECIFIED, + issues: nil, + address: "", + traceID: "", } for _, opt := range opts { if opt != nil { diff --git a/internal/xerrors/retryable.go b/internal/xerrors/retryable.go index 1c3141e8f..7253f4880 100644 --- a/internal/xerrors/retryable.go +++ b/internal/xerrors/retryable.go @@ -68,6 +68,7 @@ func Retryable(err error, opts ...RetryableErrorOption) error { re = &retryableError{ err: err, name: "CUSTOM", + backoffType: backoff.TypeNoBackoff, code: -1, isRetryObjectValid: true, } diff --git a/internal/xerrors/stacktrace.go b/internal/xerrors/stacktrace.go index 3140547d5..9c7e9b0cd 100644 --- a/internal/xerrors/stacktrace.go +++ b/internal/xerrors/stacktrace.go @@ -23,7 +23,7 @@ func WithStackTrace(err error, opts ...withStackTraceOption) error { if err == nil { return nil } - options := withStackTraceOptions{} + options := withStackTraceOptions{skipDepth: 0} for _, opt := range opts { if opt != nil { opt(&options) diff --git a/internal/xerrors/transport.go b/internal/xerrors/transport.go index b66f7735c..9650968d9 100644 --- a/internal/xerrors/transport.go +++ b/internal/xerrors/transport.go @@ -145,13 +145,17 @@ func Transport(err error, opts ...teOpt) error { } if s, ok := grpcStatus.FromError(err); ok { te = &transportError{ - status: s, - err: err, + status: s, + err: err, + address: "", + traceID: "", } } else { te = &transportError{ - status: grpcStatus.New(grpcCodes.Unknown, stack.Record(1)), - err: err, + status: grpcStatus.New(grpcCodes.Unknown, stack.Record(1)), + err: err, + address: "", + traceID: "", } } for _, opt := range opts { @@ -194,8 +198,10 @@ func TransportError(err error) Error { } if s, ok := grpcStatus.FromError(err); ok { return &transportError{ - status: s, - err: err, + status: s, + err: err, + address: "", + traceID: "", } } diff --git a/internal/xrand/xrand.go b/internal/xrand/xrand.go index 2f8ed0021..890fc0b87 100644 --- a/internal/xrand/xrand.go +++ b/internal/xrand/xrand.go @@ -33,6 +33,7 @@ func WithSeed(seed int64) option { func New(opts ...option) Rand { r := &r{ + m: &sync.Mutex{}, r: rand.New(rand.NewSource(time.Now().Unix())), //nolint:gosec } for _, opt := range opts { diff --git a/internal/xsql/conn.go b/internal/xsql/conn.go index 42d5517e1..fd3254d7c 100644 --- a/internal/xsql/conn.go +++ b/internal/xsql/conn.go @@ -8,6 +8,7 @@ import ( "io" "path" "strings" + "sync" "sync/atomic" "time" @@ -115,23 +116,32 @@ func (resultNoRows) LastInsertId() (int64, error) { return 0, ErrUnsupported } func (resultNoRows) RowsAffected() (int64, error) { return 0, ErrUnsupported } var ( - _ driver.Conn = &conn{} - _ driver.ConnPrepareContext = &conn{} - _ driver.ConnBeginTx = &conn{} - _ driver.ExecerContext = &conn{} - _ driver.QueryerContext = &conn{} - _ driver.Pinger = &conn{} - _ driver.Validator = &conn{} - _ driver.NamedValueChecker = &conn{} + _ driver.Conn = new(conn) + _ driver.ConnPrepareContext = new(conn) + _ driver.ConnBeginTx = new(conn) + _ driver.ExecerContext = new(conn) + _ driver.QueryerContext = new(conn) + _ driver.Pinger = new(conn) + _ driver.Validator = new(conn) + _ driver.NamedValueChecker = new(conn) _ driver.Result = resultNoRows{} ) func newConn(ctx context.Context, c *Connector, s table.ClosableSession, opts ...connOption) *conn { cc := &conn{ - ctx: ctx, - connector: c, - session: s, + ctx: ctx, + connector: c, + trace: nil, + session: s, + beginTxFuncs: nil, + closed: atomic.Bool{}, + lastUsage: atomic.Int64{}, + defaultQueryMode: DefaultQueryMode, + defaultTxControl: nil, + dataOpts: nil, + scanOpts: nil, + currentTx: nil, } cc.beginTxFuncs = map[QueryMode]beginTxFunc{ DataQueryMode: cc.beginTx, @@ -334,8 +344,9 @@ func (c *conn) queryContext(ctx context.Context, query string, args []driver.Nam } return &rows{ - conn: c, - result: res, + conn: c, + result: res, + nextSet: sync.Once{}, }, nil case ScanQueryMode: normalizedQuery, parameters, err := c.normalize(query, args...) @@ -353,8 +364,9 @@ func (c *conn) queryContext(ctx context.Context, query string, args []driver.Nam } return &rows{ - conn: c, - result: res, + conn: c, + result: res, + nextSet: sync.Once{}, }, nil case ExplainQueryMode: normalizedQuery, _, err := c.normalize(query, args...) @@ -371,6 +383,7 @@ func (c *conn) queryContext(ctx context.Context, query string, args []driver.Nam sql.Named("AST", exp.AST), sql.Named("Plan", exp.Plan), }, + readAll: false, }, nil case ScriptingQueryMode: normalizedQuery, parameters, err := c.normalize(query, args...) @@ -386,8 +399,9 @@ func (c *conn) queryContext(ctx context.Context, query string, args []driver.Nam } return &rows{ - conn: c, - result: res, + conn: c, + result: res, + nextSet: sync.Once{}, }, nil default: return nil, fmt.Errorf("unsupported query mode '%s' on conn query", m) diff --git a/internal/xsql/connector.go b/internal/xsql/connector.go index f097c6954..237ebea0d 100644 --- a/internal/xsql/connector.go +++ b/internal/xsql/connector.go @@ -212,13 +212,24 @@ type ydbDriver interface { func Open(parent ydbDriver, opts ...ConnectorOption) (_ *Connector, err error) { c := &Connector{ - parent: parent, - clock: clockwork.NewRealClock(), - conns: make(map[*conn]struct{}), - defaultTxControl: table.DefaultTxControl(), - defaultQueryMode: DefaultQueryMode, - pathNormalizer: bind.TablePathPrefix(parent.Name()), - trace: &trace.DatabaseSQL{}, + parent: parent, + clock: clockwork.NewRealClock(), + Bindings: bind.Bindings{}, + fakeTxModes: nil, + onClose: nil, + conns: make(map[*conn]struct{}), + connsMtx: sync.RWMutex{}, + idleStopper: nil, + defaultTxControl: table.DefaultTxControl(), + defaultQueryMode: DefaultQueryMode, + defaultDataQueryOpts: nil, + defaultScanQueryOpts: nil, + disableServerBalancer: false, + idleThreshold: time.Duration(0), + pathNormalizer: bind.TablePathPrefix(parent.Name()), + trace: nil, + traceRetry: nil, + retryBudget: nil, } for _, opt := range opts { if opt != nil { @@ -269,8 +280,8 @@ type Connector struct { } var ( - _ driver.Connector = &Connector{} - _ io.Closer = &Connector{} + _ driver.Connector = nil + _ io.Closer = nil ) func (c *Connector) idleCloser() (idleStopper func()) { diff --git a/internal/xsql/rows.go b/internal/xsql/rows.go index 356054be2..8165f7034 100644 --- a/internal/xsql/rows.go +++ b/internal/xsql/rows.go @@ -18,13 +18,13 @@ import ( ) var ( - _ driver.Rows = &rows{} - _ driver.RowsNextResultSet = &rows{} - _ driver.RowsColumnTypeDatabaseTypeName = &rows{} - _ driver.RowsColumnTypeNullable = &rows{} - _ driver.Rows = &single{} + _ driver.Rows = &rows{conn: nil, result: nil, nextSet: sync.Once{}} + _ driver.RowsNextResultSet = &rows{conn: nil, result: nil, nextSet: sync.Once{}} + _ driver.RowsColumnTypeDatabaseTypeName = &rows{conn: nil, result: nil, nextSet: sync.Once{}} + _ driver.RowsColumnTypeNullable = &rows{conn: nil, result: nil, nextSet: sync.Once{}} + _ driver.Rows = &single{values: nil, readAll: false} - _ scanner.Scanner = &valuer{} + _ scanner.Scanner = &valuer{v: nil} ignoreColumnPrefixName = "__discard_column_" ) @@ -123,7 +123,7 @@ func (r *rows) Next(dst []driver.Value) error { } values := make([]indexed.RequiredOrOptional, len(dst)) for i := range dst { - values[i] = &valuer{} + values[i] = &valuer{v: nil} } if err = r.result.Scan(values...); err != nil { return badconn.Map(xerrors.WithStackTrace(err)) diff --git a/internal/xsql/stmt.go b/internal/xsql/stmt.go index 6909e55ef..a8bb51919 100644 --- a/internal/xsql/stmt.go +++ b/internal/xsql/stmt.go @@ -24,9 +24,9 @@ type stmt struct { } var ( - _ driver.Stmt = &stmt{} - _ driver.StmtQueryContext = &stmt{} - _ driver.StmtExecContext = &stmt{} + _ driver.Stmt = &stmt{conn: nil, processor: nil, query: "", ctx: nil, trace: nil} + _ driver.StmtQueryContext = &stmt{conn: nil, processor: nil, query: "", ctx: nil, trace: nil} + _ driver.StmtExecContext = &stmt{conn: nil, processor: nil, query: "", ctx: nil, trace: nil} ) func (stmt *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (_ driver.Rows, finalErr error) { diff --git a/internal/xsql/tx.go b/internal/xsql/tx.go index 2a58e2728..c5037ab7b 100644 --- a/internal/xsql/tx.go +++ b/internal/xsql/tx.go @@ -4,6 +4,7 @@ import ( "context" "database/sql/driver" "fmt" + "sync" "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack" "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" @@ -20,10 +21,10 @@ type tx struct { } var ( - _ driver.Tx = &tx{} - _ driver.ExecerContext = &tx{} - _ driver.QueryerContext = &tx{} - _ table.TransactionIdentifier = &tx{} + _ driver.Tx = &tx{conn: nil, ctx: nil, tx: nil} + _ driver.ExecerContext = &tx{conn: nil, ctx: nil, tx: nil} + _ driver.QueryerContext = &tx{conn: nil, ctx: nil, tx: nil} + _ table.TransactionIdentifier = &tx{conn: nil, ctx: nil, tx: nil} ) func (c *conn) beginTx(ctx context.Context, txOptions driver.TxOptions) (currentTx, error) { @@ -159,8 +160,9 @@ func (tx *tx) QueryContext(ctx context.Context, query string, args []driver.Name } return &rows{ - conn: tx.conn, - result: res, + conn: tx.conn, + result: res, + nextSet: sync.Once{}, }, nil } diff --git a/internal/xsql/tx_fake.go b/internal/xsql/tx_fake.go index 0fc3efd27..a2f5568e1 100644 --- a/internal/xsql/tx_fake.go +++ b/internal/xsql/tx_fake.go @@ -39,16 +39,17 @@ func (tx *txFake) PrepareContext(ctx context.Context, query string) (_ driver.St } var ( - _ driver.Tx = &txFake{} - _ driver.ExecerContext = &txFake{} - _ driver.QueryerContext = &txFake{} - _ table.TransactionIdentifier = &txFake{} + _ driver.Tx = &txFake{beginCtx: nil, conn: nil, ctx: nil} + _ driver.ExecerContext = &txFake{beginCtx: nil, conn: nil, ctx: nil} + _ driver.QueryerContext = &txFake{beginCtx: nil, conn: nil, ctx: nil} + _ table.TransactionIdentifier = &txFake{beginCtx: nil, conn: nil, ctx: nil} ) func (c *conn) beginTxFake(ctx context.Context, txOptions driver.TxOptions) (currentTx, error) { return &txFake{ - conn: c, - ctx: ctx, + beginCtx: nil, + conn: c, + ctx: ctx, }, nil } diff --git a/internal/xstring/buffer.go b/internal/xstring/buffer.go index da47a7756..3e7b61773 100644 --- a/internal/xstring/buffer.go +++ b/internal/xstring/buffer.go @@ -11,7 +11,7 @@ type buffer struct { } var buffersPool = sync.Pool{New: func() interface{} { - return &buffer{} + return &buffer{Buffer: bytes.Buffer{}} }} func (b *buffer) Free() { diff --git a/internal/xsync/last_usage_guard.go b/internal/xsync/last_usage_guard.go index f11d5ba49..6a30bb73e 100644 --- a/internal/xsync/last_usage_guard.go +++ b/internal/xsync/last_usage_guard.go @@ -29,6 +29,8 @@ func WithClock(clock clockwork.Clock) lastUsageOption { func NewLastUsage(opts ...lastUsageOption) *lastUsage { lastUsage := &lastUsage{ + locks: atomic.Int64{}, + t: atomic.Pointer[time.Time]{}, clock: clockwork.NewRealClock(), } for _, opt := range opts { diff --git a/internal/xsync/once.go b/internal/xsync/once.go index 35f5ed0aa..76431c460 100644 --- a/internal/xsync/once.go +++ b/internal/xsync/once.go @@ -27,7 +27,7 @@ type Once[T closer.Closer] struct { } func OnceValue[T closer.Closer](f func() T) *Once[T] { - return &Once[T]{f: f} + return &Once[T]{f: f, t: f(), once: sync.Once{}, mutex: sync.RWMutex{}} } func (v *Once[T]) Close(ctx context.Context) (err error) { diff --git a/internal/xtest/logger.go b/internal/xtest/logger.go index 62bdfbe21..39fda1ea2 100644 --- a/internal/xtest/logger.go +++ b/internal/xtest/logger.go @@ -7,6 +7,7 @@ import ( func MakeSyncedTest(t testing.TB) *SyncedTest { return &SyncedTest{ + m: sync.Mutex{}, TB: t, } } diff --git a/internal/xtest/manytimes.go b/internal/xtest/manytimes.go index 9d021eb23..298d4758f 100644 --- a/internal/xtest/manytimes.go +++ b/internal/xtest/manytimes.go @@ -65,8 +65,10 @@ func runTest(t testing.TB, test TestFunc, testMutex *sync.Mutex) { t.Helper() tw := &testWrapper{ - TB: t, - m: testMutex, + TB: t, + m: testMutex, + logs: nil, + cleanup: nil, } defer tw.doCleanup() diff --git a/internal/xtest/ydb_grpc_mocks.go b/internal/xtest/ydb_grpc_mocks.go index d3816feca..207c21651 100644 --- a/internal/xtest/ydb_grpc_mocks.go +++ b/internal/xtest/ydb_grpc_mocks.go @@ -39,7 +39,7 @@ func GrpcMockTopicConnString(e fixenv.Env, topicServiceImpl Ydb_Topic_V1.TopicSe return fixenv.NewGenericResultWithCleanup(connString, clean), nil } - return fixenv.CacheResult(e, f, fixenv.CacheOptions{CacheKey: addr}) + return fixenv.CacheResult(e, f, fixenv.CacheOptions{Scope: 0, CacheKey: addr}) } type grpcMock struct { @@ -95,8 +95,9 @@ type mockDiscoveryService struct { func newMockDiscoveryService(host string, port uint32) *mockDiscoveryService { return &mockDiscoveryService{ - host: host, - port: port, + UnimplementedDiscoveryServiceServer: Ydb_Discovery_V1.UnimplementedDiscoveryServiceServer{}, + host: host, + port: port, } } @@ -121,10 +122,13 @@ func (m mockDiscoveryService) ListEndpoints( } resp := &Ydb_Discovery.ListEndpointsResponse{ Operation: &Ydb_Operations.Operation{ - Id: "test-list-operation", - Ready: true, - Status: Ydb.StatusIds_SUCCESS, - Result: &anypb.Any{}, + Id: "test-list-operation", + Ready: true, + Status: Ydb.StatusIds_SUCCESS, + Issues: nil, + Result: &anypb.Any{TypeUrl: "", Value: nil}, + Metadata: &anypb.Any{TypeUrl: "", Value: nil}, + CostInfo: nil, }, } err := resp.GetOperation().GetResult().MarshalFrom(res) diff --git a/log/driver.go b/log/driver.go index 7972d0f07..db66137a2 100644 --- a/log/driver.go +++ b/log/driver.go @@ -498,5 +498,11 @@ func internalDriver(l Logger, d trace.Detailer) trace.Driver { //nolint:gocyclo } } }, + OnWith: nil, + OnPoolNew: nil, + OnPoolRelease: nil, + OnConnPark: nil, + OnBalancerClusterDiscoveryAttempt: nil, + OnConnStreamFinish: nil, } } diff --git a/log/field.go b/log/field.go index 17479d3c6..9cc0fac26 100644 --- a/log/field.go +++ b/log/field.go @@ -213,6 +213,8 @@ func String(k, v string) Field { ftype: StringType, key: k, vstr: v, + vint: 0, + vany: nil, } } @@ -222,6 +224,8 @@ func Int(k string, v int) Field { ftype: IntType, key: k, vint: int64(v), + vstr: "", + vany: nil, } } @@ -230,6 +234,8 @@ func Int64(k string, v int64) Field { ftype: Int64Type, key: k, vint: v, + vstr: "", + vany: nil, } } @@ -246,6 +252,8 @@ func Bool(key string, value bool) Field { ftype: BoolType, key: key, vint: vint, + vstr: "", + vany: nil, } } @@ -255,6 +263,8 @@ func Duration(key string, value time.Duration) Field { ftype: DurationType, key: key, vint: value.Nanoseconds(), + vstr: "", + vany: nil, } } @@ -264,6 +274,8 @@ func Strings(key string, value []string) Field { ftype: StringsType, key: key, vany: value, + vint: 0, + vstr: "", } } @@ -273,6 +285,8 @@ func NamedError(key string, value error) Field { ftype: ErrorType, key: key, vany: value, + vint: 0, + vstr: "", } } @@ -287,6 +301,8 @@ func Any(key string, value interface{}) Field { ftype: AnyType, key: key, vany: value, + vint: 0, + vstr: "", } } @@ -301,6 +317,8 @@ func Stringer(key string, value fmt.Stringer) Field { ftype: StringerType, key: key, vany: value, + vint: 0, + vstr: "", } } diff --git a/log/logger.go b/log/logger.go index 8caf7229a..84ccf6f86 100644 --- a/log/logger.go +++ b/log/logger.go @@ -29,6 +29,7 @@ type simpleLoggerOption interface { func Default(w io.Writer, opts ...simpleLoggerOption) *defaultLogger { l := &defaultLogger{ coloring: false, + logQuery: false, minLevel: INFO, clock: clockwork.NewRealClock(), w: w, @@ -104,7 +105,8 @@ type wrapper struct { func wrapLogger(l Logger, opts ...Option) *wrapper { ll := &wrapper{ - logger: l, + logQuery: false, + logger: l, } for _, opt := range opts { if opt != nil { diff --git a/log/query.go b/log/query.go index e44e9e3ac..f964c9301 100644 --- a/log/query.go +++ b/log/query.go @@ -649,5 +649,6 @@ func internalQuery( } } }, + OnPoolChange: nil, } } diff --git a/retry/budget/budget.go b/retry/budget/budget.go index 2f2625178..94d78e9e3 100644 --- a/retry/budget/budget.go +++ b/retry/budget/budget.go @@ -39,8 +39,10 @@ func withFixedBudgetClock(clock clockwork.Clock) fixedBudgetOption { // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental func Limited(attemptsPerSecond int, opts ...fixedBudgetOption) *fixedBudget { q := &fixedBudget{ - clock: clockwork.NewRealClock(), - done: make(chan struct{}), + clock: clockwork.NewRealClock(), + ticker: nil, + quota: nil, + done: make(chan struct{}), } for _, opt := range opts { opt(q) diff --git a/retry/retry.go b/retry/retry.go index c2e601603..b5b8cdaab 100644 --- a/retry/retry.go +++ b/retry/retry.go @@ -103,7 +103,7 @@ func WithStackTrace() stackTraceOption { return stackTraceOption{} } -var _ Option = traceOption{} +var _ Option = traceOption{t: nil} type traceOption struct { t *trace.Retry @@ -126,7 +126,7 @@ func WithTrace(t *trace.Retry) traceOption { return traceOption{t: t} } -var _ Option = budgetOption{} +var _ Option = budgetOption{b: nil} type budgetOption struct { b budget.Budget @@ -172,7 +172,7 @@ func WithIdempotent(idempotent bool) idempotentOption { return idempotentOption(idempotent) } -var _ Option = fastBackoffOption{} +var _ Option = fastBackoffOption{backoff: nil} type fastBackoffOption struct { backoff backoff.Backoff @@ -197,7 +197,7 @@ func WithFastBackoff(b backoff.Backoff) fastBackoffOption { return fastBackoffOption{backoff: b} } -var _ Option = slowBackoffOption{} +var _ Option = slowBackoffOption{backoff: nil} type slowBackoffOption struct { backoff backoff.Backoff @@ -222,7 +222,7 @@ func WithSlowBackoff(b backoff.Backoff) slowBackoffOption { return slowBackoffOption{backoff: b} } -var _ Option = panicCallbackOption{} +var _ Option = panicCallbackOption{callback: nil} type panicCallbackOption struct { callback func(e interface{}) @@ -261,11 +261,15 @@ func WithPanicCallback(panicCallback func(e interface{})) panicCallbackOption { //nolint:funlen func Retry(ctx context.Context, op retryOperation, opts ...Option) (finalErr error) { options := &retryOptions{ - call: stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/retry.Retry"), - trace: &trace.Retry{}, - budget: budget.Limited(-1), - fastBackoff: backoff.Fast, - slowBackoff: backoff.Slow, + label: "", + call: stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/retry.Retry"), + trace: new(trace.Retry), + idempotent: false, + stackTrace: false, + fastBackoff: backoff.Fast, + slowBackoff: backoff.Slow, + budget: budget.Limited(-1), + panicCallback: nil, } for _, opt := range opts { if opt != nil { diff --git a/retry/sql.go b/retry/sql.go index 5bf974351..957667df0 100644 --- a/retry/sql.go +++ b/retry/sql.go @@ -112,7 +112,7 @@ func WithDoTxRetryOptions(opts ...Option) doTxRetryOptionsOption { return opts } -var _ doTxOption = txOptionsOption{} +var _ doTxOption = txOptionsOption{txOptions: nil} type txOptionsOption struct { txOptions *sql.TxOptions diff --git a/scheme/scheme.go b/scheme/scheme.go index 1aeac9777..cd335c66c 100644 --- a/scheme/scheme.go +++ b/scheme/scheme.go @@ -171,7 +171,13 @@ func (p Permissions) To(y *Ydb_Scheme.Permissions) { } func InnerConvertEntry(y *Ydb_Scheme.Entry) *Entry { - res := &Entry{} + res := &Entry{ + Name: "", + Owner: "", + Type: EntryTypeUnknown, + Permissions: nil, + EffectivePermissions: nil, + } res.From(y) return res diff --git a/sql.go b/sql.go index 0ec78b964..77934e16e 100644 --- a/sql.go +++ b/sql.go @@ -5,6 +5,7 @@ import ( "database/sql" "database/sql/driver" "fmt" + "sync" "github.com/ydb-platform/ydb-go-sdk/v3/internal/bind" "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" @@ -15,7 +16,10 @@ import ( "github.com/ydb-platform/ydb-go-sdk/v3/trace" ) -var d = &sqlDriver{connectors: make(map[*xsql.Connector]*Driver)} //nolint:gochecknoglobals +var d = &sqlDriver{ + connectors: make(map[*xsql.Connector]*Driver), + connectorsMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}, +} //nolint:gochecknoglobals func init() { //nolint:gochecknoinits sql.Register("ydb", d) @@ -36,8 +40,8 @@ type sqlDriver struct { } var ( - _ driver.Driver = &sqlDriver{} - _ driver.DriverContext = &sqlDriver{} + _ driver.Driver = &sqlDriver{connectors: nil, connectorsMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}} + _ driver.DriverContext = &sqlDriver{connectors: nil, connectorsMtx: xsync.RWMutex{RWMutex: sync.RWMutex{}}} ) func (d *sqlDriver) Close() error { diff --git a/sugar/dsn.go b/sugar/dsn.go index b94e5fc57..fd3c0219a 100644 --- a/sugar/dsn.go +++ b/sugar/dsn.go @@ -13,10 +13,17 @@ func DSN(endpoint, database string, secure bool) (s string) { qp := url.Values{} dsn := url.URL{ - Scheme: "grpc", - Host: endpoint, - Path: database, - RawQuery: qp.Encode(), + Scheme: "grpc", + Host: endpoint, + Path: database, + RawQuery: qp.Encode(), + Opaque: "", + User: nil, + RawPath: "", + OmitHost: false, + ForceQuery: false, + Fragment: "", + RawFragment: "", } if secure { diff --git a/sugar/result.go b/sugar/result.go index 4a2275dcf..967a04b9f 100644 --- a/sugar/result.go +++ b/sugar/result.go @@ -76,6 +76,8 @@ func (r *result) Close() error { // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental func Result(r query.Result) *result { return &result{ - r: r, + r: r, + rs: nil, + row: nil, } } diff --git a/table/options/models.go b/table/options/models.go index eb875e63d..e521bd5e0 100644 --- a/table/options/models.go +++ b/table/options/models.go @@ -258,6 +258,7 @@ func (ps PartitioningSettings) toYDB() *Ydb_Table.PartitioningSettings { PartitioningByLoad: ps.PartitioningByLoad.ToYDB(), MinPartitionsCount: ps.MinPartitionsCount, MaxPartitionsCount: ps.MaxPartitionsCount, + PartitionBy: nil, } } @@ -450,7 +451,10 @@ const ( func NewTTLSettings() TimeToLiveSettings { return TimeToLiveSettings{ - Mode: TimeToLiveModeDateType, + Mode: TimeToLiveModeDateType, + ColumnName: "", + ExpireAfterSeconds: 0, + ColumnUnit: nil, } } @@ -517,6 +521,7 @@ func (ttl *TimeToLiveSettings) ToYDB() *Ydb_Table.TtlSettings { ExpireAfterSeconds: ttl.ExpireAfterSeconds, }, }, + RunIntervalSeconds: 0, } default: // currently use TimeToLiveModeDateType mode as default return &Ydb_Table.TtlSettings{ @@ -526,6 +531,7 @@ func (ttl *TimeToLiveSettings) ToYDB() *Ydb_Table.TtlSettings { ExpireAfterSeconds: ttl.ExpireAfterSeconds, }, }, + RunIntervalSeconds: 0, } } } diff --git a/table/options/options.go b/table/options/options.go index 922333a17..b8e474b05 100644 --- a/table/options/options.go +++ b/table/options/options.go @@ -58,15 +58,17 @@ type column struct { func (c column) ApplyAlterTableOption(d *AlterTableDesc, a *allocator.Allocator) { d.AddColumns = append(d.AddColumns, &Ydb_Table.ColumnMeta{ - Name: c.name, - Type: types.TypeToYDB(c.typ, a), + Name: c.name, + Type: types.TypeToYDB(c.typ, a), + Family: "", }) } func (c column) ApplyCreateTableOption(d *CreateTableDesc, a *allocator.Allocator) { d.Columns = append(d.Columns, &Ydb_Table.ColumnMeta{ - Name: c.name, - Type: types.TypeToYDB(c.typ, a), + Name: c.name, + Type: types.TypeToYDB(c.typ, a), + Family: "", }) } @@ -158,7 +160,10 @@ type index struct { func (i index) ApplyAlterTableOption(d *AlterTableDesc, a *allocator.Allocator) { x := &Ydb_Table.TableIndex{ - Name: i.name, + Name: i.name, + IndexColumns: nil, + Type: nil, + DataColumns: nil, } for _, opt := range i.opts { if opt != nil { @@ -170,7 +175,10 @@ func (i index) ApplyAlterTableOption(d *AlterTableDesc, a *allocator.Allocator) func (i index) ApplyCreateTableOption(d *CreateTableDesc, a *allocator.Allocator) { x := &Ydb_Table.TableIndex{ - Name: i.name, + Name: i.name, + IndexColumns: nil, + Type: nil, + DataColumns: nil, } for _, opt := range i.opts { if opt != nil { @@ -599,7 +607,7 @@ func WithPartitioningSettingsObject(ps PartitioningSettings) CreateTableOption { type partitioningSettings []PartitioningSettingsOption func (opts partitioningSettings) ApplyCreateTableOption(d *CreateTableDesc, a *allocator.Allocator) { - settings := &ydbPartitioningSettings{} + settings := new(ydbPartitioningSettings) for _, opt := range opts { if opt != nil { opt.ApplyPartitioningSettingsOption(settings) @@ -732,7 +740,8 @@ func WithAddAttribute(key, value string) AlterTableOption { // WithDropAttribute drops attribute from table in AlterTable request func WithDropAttribute(key string) AlterTableOption { return attribute{ - key: key, + key: key, + value: "", } } @@ -782,7 +791,7 @@ func WithSetTimeToLiveSettings(settings TimeToLiveSettings) AlterTableOption { type dropTimeToLive struct{} func (dropTimeToLive) ApplyAlterTableOption(d *AlterTableDesc, a *allocator.Allocator) { - d.TtlAction = &Ydb_Table.AlterTableRequest_DropTtlSettings{} + d.TtlAction = &Ydb_Table.AlterTableRequest_DropTtlSettings{DropTtlSettings: nil} } // WithDropTimeToLive drops TTL settings in AlterTable request @@ -1039,11 +1048,11 @@ func WithExecuteScanQueryStats(stats ExecuteScanQueryStatsType) ExecuteScanQuery var ( _ ReadRowsOption = readColumnsOption{} _ ReadTableOption = readOrderedOption{} - _ ReadTableOption = readKeyRangeOption{} - _ ReadTableOption = readGreaterOrEqualOption{} - _ ReadTableOption = readLessOrEqualOption{} - _ ReadTableOption = readLessOption{} - _ ReadTableOption = readGreaterOption{} + _ ReadTableOption = readKeyRangeOption{From: nil, To: nil} + _ ReadTableOption = readGreaterOrEqualOption{Value: nil} + _ ReadTableOption = readLessOrEqualOption{Value: nil} + _ ReadTableOption = readLessOption{Value: nil} + _ ReadTableOption = readGreaterOption{Value: nil} _ ReadTableOption = readRowLimitOption(0) ) diff --git a/table/table.go b/table/table.go index 86e110040..9907cf658 100644 --- a/table/table.go +++ b/table/table.go @@ -540,7 +540,7 @@ func WithIdempotent() retryOptionsOption { return []retry.Option{retry.WithIdempotent(true)} } -var _ Option = txSettingsOption{} +var _ Option = txSettingsOption{txSettings: nil} type txSettingsOption struct { txSettings *TransactionSettings @@ -566,7 +566,7 @@ func WithTxCommitOptions(opts ...options.CommitTransactionOption) txCommitOption return opts } -var _ Option = traceOption{} +var _ Option = traceOption{t: nil} type traceOption struct { t *trace.Table diff --git a/tests/slo/database/sql/storage.go b/tests/slo/database/sql/storage.go index 0fb188e54..cc54cc35e 100755 --- a/tests/slo/database/sql/storage.go +++ b/tests/slo/database/sql/storage.go @@ -89,6 +89,9 @@ func NewStorage(ctx context.Context, cfg *config.Config, poolSize int) (s *Stora retryBudget := budget.Limited(int(float64(poolSize) * 0.1)) //nolint:gomnd s = &Storage{ + cc: nil, + c: nil, + db: nil, cfg: cfg, createQuery: fmt.Sprintf(createTemplate, cfg.Table, cfg.PartitionSize, cfg.MinPartitionsCount, cfg.MaxPartitionsCount, cfg.MinPartitionsCount), diff --git a/tests/slo/gorm/storage.go b/tests/slo/gorm/storage.go index 48d3042e4..029a5e94f 100644 --- a/tests/slo/gorm/storage.go +++ b/tests/slo/gorm/storage.go @@ -54,6 +54,7 @@ func NewStorage(cfg *config.Config, poolSize int) (*Storage, error) { cfg: cfg, tableOptions: fmt.Sprintf(optionsTemplate, cfg.PartitionSize, cfg.MinPartitionsCount, cfg.MaxPartitionsCount, cfg.MinPartitionsCount), + db: nil, } var err error @@ -68,7 +69,25 @@ func NewStorage(cfg *config.Config, poolSize int) (*Storage, error) { ), ), &gorm.Config{ - Logger: gormLogger.Default.LogMode(gormLogger.Warn), + Logger: gormLogger.Default.LogMode(gormLogger.Warn), + SkipDefaultTransaction: false, + NamingStrategy: nil, + FullSaveAssociations: false, + NowFunc: nil, + DryRun: false, + PrepareStmt: false, + DisableAutomaticPing: false, + DisableForeignKeyConstraintWhenMigrating: false, + IgnoreRelationshipsWhenMigrating: false, + DisableNestedTransaction: false, + AllowGlobalUpdate: false, + QueryFields: false, + CreateBatchSize: 0, + TranslateError: false, + ClauseBuilders: nil, + ConnPool: nil, + Dialector: nil, + Plugins: nil, }, ) if err != nil { @@ -97,11 +116,12 @@ func (s *Storage) Read(ctx context.Context, id generator.RowID) (r generator.Row return err } - err = s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)).Model(&generator.Row{}). + err = s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)).Model(new(generator.Row)). First(&r, "hash = ? AND id = ?", clause.Expr{ - SQL: "Digest::NumericHash(?)", - Vars: []interface{}{id}, + SQL: "Digest::NumericHash(?)", + Vars: []interface{}{id}, + WithoutParentheses: false, }, id, ).Error @@ -145,11 +165,12 @@ func (s *Storage) Write(ctx context.Context, row generator.Row) (attempts int, e return err } - return s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)).Model(&generator.Row{}). + return s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)).Model(new(generator.Row)). Create(map[string]interface{}{ "Hash": clause.Expr{ - SQL: "Digest::NumericHash(?)", - Vars: []interface{}{row.ID}, + SQL: "Digest::NumericHash(?)", + Vars: []interface{}{row.ID}, + WithoutParentheses: false, }, "ID": row.ID, "PayloadStr": row.PayloadStr, @@ -181,7 +202,7 @@ func (s *Storage) createTable(ctx context.Context) error { defer cancel() return s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)). - Set("gorm:table_options", s.tableOptions).AutoMigrate(&generator.Row{}) + Set("gorm:table_options", s.tableOptions).AutoMigrate(new(generator.Row)) } func (s *Storage) dropTable(ctx context.Context) error { @@ -192,7 +213,7 @@ func (s *Storage) dropTable(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctx, time.Duration(s.cfg.WriteTimeout)*time.Millisecond) defer cancel() - return s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)).Migrator().DropTable(&generator.Row{}) + return s.db.WithContext(ctx).Scopes(addTableToScope(s.cfg.Table)).Migrator().DropTable(new(generator.Row)) } func (s *Storage) close(ctx context.Context) error { diff --git a/tests/slo/internal/config/config.go b/tests/slo/internal/config/config.go index 612bc0ae3..28364b7ad 100644 --- a/tests/slo/internal/config/config.go +++ b/tests/slo/internal/config/config.go @@ -37,7 +37,7 @@ type Config struct { //nolint:gomnd func New() (*Config, error) { - cfg := &Config{} + cfg := new(Config) if len(os.Args) < 2 { fmt.Print(mainHelp) @@ -45,7 +45,7 @@ func New() (*Config, error) { return nil, ErrWrongArgs } - fs := flag.FlagSet{} + fs := flag.FlagSet{Usage: nil} switch os.Args[1] { case "create": diff --git a/tests/slo/internal/generator/generator.go b/tests/slo/internal/generator/generator.go index 275ccd41c..3bc90fdf8 100755 --- a/tests/slo/internal/generator/generator.go +++ b/tests/slo/internal/generator/generator.go @@ -21,6 +21,7 @@ type Generator struct { func New(id RowID) *Generator { return &Generator{ currentID: id, + mu: sync.Mutex{}, } } @@ -33,6 +34,9 @@ func (g *Generator) Generate() (Row, error) { ID: id, PayloadDouble: func(a float64) *float64 { return &a }(rand.Float64()), //nolint:gosec // speed more important PayloadTimestamp: func(a time.Time) *time.Time { return &a }(time.Now()), + Hash: 0, + PayloadStr: nil, + PayloadHash: 0, } var err error diff --git a/tests/slo/internal/metrics/metrics.go b/tests/slo/internal/metrics/metrics.go index 67b4af470..bf411dc86 100644 --- a/tests/slo/internal/metrics/metrics.go +++ b/tests/slo/internal/metrics/metrics.go @@ -30,48 +30,76 @@ type ( func New(url, label, jobName string) (*Metrics, error) { m := &Metrics{ - label: label, + label: label, + oks: nil, + notOks: nil, + inflight: nil, + latencies: nil, + attempts: nil, + p: nil, } m.oks = prometheus.NewGaugeVec( prometheus.GaugeOpts{ - Name: "oks", - Help: "amount of OK requests", + Name: "oks", + Help: "amount of OK requests", + Namespace: "", + Subsystem: "", + ConstLabels: nil, }, []string{"jobName"}, ) m.notOks = prometheus.NewGaugeVec( prometheus.GaugeOpts{ - Name: "not_oks", - Help: "amount of not OK requests", + Name: "not_oks", + Help: "amount of not OK requests", + Namespace: "", + Subsystem: "", + ConstLabels: nil, }, []string{"jobName"}, ) m.inflight = prometheus.NewGaugeVec( prometheus.GaugeOpts{ - Name: "inflight", - Help: "amount of requests in flight", + Name: "inflight", + Help: "amount of requests in flight", + Namespace: "", + Subsystem: "", + ConstLabels: nil, }, []string{"jobName"}, ) m.latencies = prometheus.NewSummaryVec( prometheus.SummaryOpts{ - Name: "latency", - Help: "summary of latencies in ms", + Namespace: "", + Subsystem: "", + Name: "latency", + Help: "summary of latencies in ms", + ConstLabels: nil, Objectives: map[float64]float64{ 0.5: 0, 0.99: 0, 1.0: 0, }, - MaxAge: 15 * time.Second, //nolint:gomnd + MaxAge: 15 * time.Second, //nolint:gomnd + AgeBuckets: 0, + BufCap: 0, }, []string{"status", "jobName"}, ) m.attempts = prometheus.NewHistogramVec( prometheus.HistogramOpts{ - Name: "attempts", - Help: "summary of amount for request", - Buckets: prometheus.LinearBuckets(1, 1, 10), //nolint:gomnd + Namespace: "", + Subsystem: "", + Name: "attempts", + Help: "summary of amount for request", + ConstLabels: nil, + Buckets: prometheus.LinearBuckets(1, 1, 10), //nolint:gomnd + NativeHistogramBucketFactor: 0, + NativeHistogramZeroThreshold: 0, + NativeHistogramMaxBucketNumber: 0, + NativeHistogramMinResetDuration: 0, + NativeHistogramMaxZeroThreshold: 0, }, []string{"status", "jobName"}, ) diff --git a/tests/slo/native/query/storage.go b/tests/slo/native/query/storage.go index a806775fd..51eb7b460 100755 --- a/tests/slo/native/query/storage.go +++ b/tests/slo/native/query/storage.go @@ -104,7 +104,7 @@ func (s *Storage) Read(ctx context.Context, entryID generator.RowID) (_ generato ctx, cancel := context.WithTimeout(ctx, time.Duration(s.cfg.ReadTimeout)*time.Millisecond) defer cancel() - e := generator.Row{} + e := generator.Row{Hash: 0, ID: 0, PayloadStr: nil, PayloadDouble: nil, PayloadTimestamp: nil, PayloadHash: 0} err := s.db.Query().Do(ctx, func(ctx context.Context, session query.Session) (err error) { @@ -163,6 +163,30 @@ func (s *Storage) Read(ctx context.Context, entryID generator.RowID) (_ generato attempts = info.Attempts } }, + OnNew: nil, + OnClose: nil, + OnPoolNew: nil, + OnPoolClose: nil, + OnPoolTry: nil, + OnPoolWith: nil, + OnPoolPut: nil, + OnPoolGet: nil, + OnPoolChange: nil, + OnDoTx: nil, + OnSessionCreate: nil, + OnSessionAttach: nil, + OnSessionDelete: nil, + OnSessionExecute: nil, + OnSessionBegin: nil, + OnTxExecute: nil, + OnResultNew: nil, + OnResultNextPart: nil, + OnResultNextResultSet: nil, + OnResultClose: nil, + OnResultSetNextRow: nil, + OnRowScan: nil, + OnRowScanNamed: nil, + OnRowScanStruct: nil, }), query.WithLabel("READ"), ) @@ -212,6 +236,30 @@ func (s *Storage) Write(ctx context.Context, e generator.Row) (attempts int, fin attempts = info.Attempts } }, + OnNew: nil, + OnClose: nil, + OnPoolNew: nil, + OnPoolClose: nil, + OnPoolTry: nil, + OnPoolWith: nil, + OnPoolPut: nil, + OnPoolGet: nil, + OnPoolChange: nil, + OnDoTx: nil, + OnSessionCreate: nil, + OnSessionAttach: nil, + OnSessionDelete: nil, + OnSessionExecute: nil, + OnSessionBegin: nil, + OnTxExecute: nil, + OnResultNew: nil, + OnResultNextPart: nil, + OnResultNextResultSet: nil, + OnResultClose: nil, + OnResultSetNextRow: nil, + OnRowScan: nil, + OnRowScanNamed: nil, + OnRowScanStruct: nil, }), query.WithLabel("WRITE"), ) diff --git a/tests/slo/native/table/storage.go b/tests/slo/native/table/storage.go index affd5f60b..06a866e4a 100755 --- a/tests/slo/native/table/storage.go +++ b/tests/slo/native/table/storage.go @@ -108,7 +108,7 @@ func (s *Storage) Read(ctx context.Context, entryID generator.RowID) (_ generato ctx, cancel := context.WithTimeout(ctx, time.Duration(s.cfg.ReadTimeout)*time.Millisecond) defer cancel() - e := generator.Row{} + e := generator.Row{Hash: 0, ID: 0, PayloadStr: nil, PayloadDouble: nil, PayloadTimestamp: nil, PayloadHash: 0} err = s.db.Table().Do(ctx, func(ctx context.Context, session table.Session) (err error) { @@ -157,6 +157,30 @@ func (s *Storage) Read(ctx context.Context, entryID generator.RowID) (_ generato attempts = info.Attempts } }, + OnInit: nil, + OnClose: nil, + OnDoTx: nil, + OnCreateSession: nil, + OnSessionNew: nil, + OnSessionDelete: nil, + OnSessionKeepAlive: nil, + OnSessionBulkUpsert: nil, + OnSessionQueryPrepare: nil, + OnSessionQueryExecute: nil, + OnSessionQueryExplain: nil, + OnSessionQueryStreamExecute: nil, + OnSessionQueryStreamRead: nil, + OnTxBegin: nil, + OnTxExecute: nil, + OnTxExecuteStatement: nil, + OnTxCommit: nil, + OnTxRollback: nil, + OnPoolStateChange: nil, + OnPoolSessionAdd: nil, + OnPoolSessionRemove: nil, + OnPoolPut: nil, + OnPoolGet: nil, + OnPoolWait: nil, }), ) @@ -203,6 +227,30 @@ func (s *Storage) Write(ctx context.Context, e generator.Row) (attempts int, _ e attempts = info.Attempts } }, + OnInit: nil, + OnClose: nil, + OnDoTx: nil, + OnCreateSession: nil, + OnSessionNew: nil, + OnSessionDelete: nil, + OnSessionKeepAlive: nil, + OnSessionBulkUpsert: nil, + OnSessionQueryPrepare: nil, + OnSessionQueryExecute: nil, + OnSessionQueryExplain: nil, + OnSessionQueryStreamExecute: nil, + OnSessionQueryStreamRead: nil, + OnTxBegin: nil, + OnTxExecute: nil, + OnTxExecuteStatement: nil, + OnTxCommit: nil, + OnTxRollback: nil, + OnPoolStateChange: nil, + OnPoolSessionAdd: nil, + OnPoolSessionRemove: nil, + OnPoolPut: nil, + OnPoolGet: nil, + OnPoolWait: nil, }), ) diff --git a/tests/slo/xorm/storage.go b/tests/slo/xorm/storage.go index 4550374c9..7d6da8104 100644 --- a/tests/slo/xorm/storage.go +++ b/tests/slo/xorm/storage.go @@ -65,6 +65,10 @@ type Storage struct { func NewStorage(ctx context.Context, cfg *config.Config, poolSize int) (_ *Storage, err error) { s := &Storage{ cfg: cfg, + cc: nil, + c: nil, + db: nil, + x: nil, } dsn := s.cfg.Endpoint + s.cfg.DB @@ -195,7 +199,9 @@ func (s *Storage) createTable(ctx context.Context) error { defer cancel() return retry.Do(ctx, s.x.DB().DB, func(ctx context.Context, _ *sql.Conn) error { - return s.x.Context(ctx).CreateTable(generator.Row{}) + return s.x.Context(ctx).CreateTable(generator.Row{ + Hash: 0, ID: 0, PayloadStr: nil, PayloadDouble: nil, PayloadTimestamp: nil, PayloadHash: 0, + }) }) } @@ -208,7 +214,9 @@ func (s *Storage) dropTable(ctx context.Context) error { defer cancel() return retry.Do(ctx, s.x.DB().DB, func(ctx context.Context, _ *sql.Conn) error { - return s.x.Context(ctx).DropTable(generator.Row{}) + return s.x.Context(ctx).DropTable(generator.Row{ + Hash: 0, ID: 0, PayloadStr: nil, PayloadDouble: nil, PayloadTimestamp: nil, PayloadHash: 0, + }) }) } diff --git a/testutil/driver.go b/testutil/driver.go index 48b82d4ca..a14c1151b 100644 --- a/testutil/driver.go +++ b/testutil/driver.go @@ -6,6 +6,7 @@ import ( "reflect" "strings" + "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Operations" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -173,6 +174,7 @@ func (b *balancerStub) Get(context.Context) (conn grpc.ClientConnInterface, err cc := &clientConn{ onInvoke: b.onInvoke, onNewStream: b.onNewStream, + onAddress: nil, } return cc, nil @@ -217,7 +219,13 @@ func WithInvokeHandlers(invokeHandlers InvokeHandlers) balancerOption { "Operation", reply, &Ydb_Operations.Operation{ - Result: anyResult, + Result: anyResult, + Id: "", + Ready: false, + Status: Ydb.StatusIds_STATUS_CODE_UNSPECIFIED, + Issues: nil, + Metadata: nil, + CostInfo: nil, }, ) @@ -247,7 +255,7 @@ func WithNewStreamHandlers(newStreamHandlers NewStreamHandlers) balancerOption { } func NewBalancer(opts ...balancerOption) *balancerStub { - c := &balancerStub{} + c := &balancerStub{onInvoke: nil, onNewStream: nil} for _, opt := range opts { if opt != nil { opt(c) diff --git a/topic/topicoptions/topicoptions_alter.go b/topic/topicoptions/topicoptions_alter.go index 52700a7f4..b119319c8 100644 --- a/topic/topicoptions/topicoptions_alter.go +++ b/topic/topicoptions/topicoptions_alter.go @@ -4,7 +4,9 @@ import ( "sort" "time" + "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawoptional" "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic" + "github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopiccommon" "github.com/ydb-platform/ydb-go-sdk/v3/topic/topictypes" ) @@ -126,7 +128,13 @@ func ensureAlterConsumer( return consumers, i } } - consumers = append(consumers, rawtopic.AlterConsumer{Name: name}) + consumers = append(consumers, rawtopic.AlterConsumer{ + Name: name, + SetImportant: rawoptional.Bool{Value: false, HasValue: false}, + SetReadFrom: rawoptional.Time{Value: time.Time{}, HasValue: false}, + SetSupportedCodecs: rawtopiccommon.SupportedCodecs{}, + AlterAttributes: nil, + }) return consumers, len(consumers) - 1 } diff --git a/topic/topicoptions/topicoptions_reader.go b/topic/topicoptions/topicoptions_reader.go index dfc7661a5..850b9ce36 100644 --- a/topic/topicoptions/topicoptions_reader.go +++ b/topic/topicoptions/topicoptions_reader.go @@ -18,7 +18,7 @@ type ReadSelectors []ReadSelector // ReadTopic create simple selector for read topics, if no need special settings. func ReadTopic(path string) ReadSelectors { - return ReadSelectors{{Path: path}} + return ReadSelectors{{Path: path, Partitions: nil, ReadFrom: time.Time{}, MaxTimeLag: time.Duration(0)}} } // ReaderOption options for topic reader diff --git a/topic/topicreader/reader.go b/topic/topicreader/reader.go index ec8f43b5e..9831e2b86 100644 --- a/topic/topicreader/reader.go +++ b/topic/topicreader/reader.go @@ -28,7 +28,7 @@ type Reader struct { // NewReader // create new reader, used internally only. func NewReader(internalReader topicreaderinternal.Reader) *Reader { - return &Reader{reader: internalReader} + return &Reader{reader: internalReader, readInFlyght: atomic.Bool{}, commitInFlyght: atomic.Bool{}} } // WaitInit waits until the reader is initialized diff --git a/trace/details.go b/trace/details.go index a60fdb6d2..a9d96f87d 100644 --- a/trace/details.go +++ b/trace/details.go @@ -202,6 +202,7 @@ func MatchDetails(pattern string, opts ...matchDetailsOption) (d Details) { var ( h = &matchDetailsOptionsHolder{ defaultDetails: defaultDetails, + posixMatch: false, } re *regexp.Regexp err error