Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dlc-01 authored Feb 19, 2024
2 parents 87bdfe9 + 9ca8650 commit 832da85
Show file tree
Hide file tree
Showing 310 changed files with 2,346 additions and 199 deletions.
9 changes: 6 additions & 3 deletions .github/scripts/format-go-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ FILEPATH="$1"

gofmt -s -w "$FILEPATH"

# https://github.com/rinchsan/gosimports
# https://github.com/daixiang0/gci
if [[ "$FILEPATH" == *"tests/slo/"* ]]
then
gosimports -local slo -w "$FILEPATH"
gci write --skip-generated -s standard -s default -s "prefix(slo)" "$FILEPATH"
elif [[ "$FILEPATH" == *"examples/"* ]]
then
gci write --skip-generated -s standard -s default -s "prefix(examples)" "$FILEPATH"
else
gosimports -local github.com/ydb-platform/ydb-go-sdk/v3 -w "$FILEPATH"
gci write --skip-generated -s standard -s default -s "prefix(github.com/ydb-platform/ydb-go-sdk/v3)" "$FILEPATH"
fi


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
go-version: [1.20.x, 1.21.x]
go-version: [1.21.x, 1.22.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Install utilities
run: |
go install mvdan.cc/[email protected]
go install github.com/rinchsan/gosimports/cmd/gosimports@v0.1.5
go install github.com/daixiang0/gci@v0.12.1
- name: format all files with auto-formatter
run: bash ./.github/scripts/format-all-go-code.sh "$PWD"
- name: Check repository diff
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
TAG="v$MAJOR.$MINOR.$PATCH";
fi;
git tag $TAG
git push --tags && git push
git push && git push --tags
CHANGELOG="$CHANGELOG
Full Changelog: [$LAST_TAG...$TAG](https://github.com/ydb-platform/ydb-go-sdk/compare/$LAST_TAG...$TAG)"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.20.x, 1.21.x]
go-version: [1.21.x, 1.22.x]
os: [ubuntu, windows, macOS]
env:
OS: ${{ matrix.os }}-latest
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.20.x, 1.21.x]
go-version: [1.21.x, 1.22.x]
ydb-version: [22.5, 23.1, 23.2, 23.3]
services:
ydb:
Expand Down
10 changes: 6 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ linters-settings:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/ydb-platform/ydb-go-sdk/v3
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/ydb-platform/ydb-go-sdk/v3) # Custom section: groups all imports with the specified Prefix.
skip-generated: true
goconst:
# minimal length of string constant, 3 by default
min-len: 2
Expand Down Expand Up @@ -220,7 +226,6 @@ linters:
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gocognit
- godot
Expand All @@ -230,12 +235,9 @@ linters:
- gomoddirectives
- ifshort
- interfacebloat
- interfacer
- ireturn
- maintidx
- maligned
- nilerr
- nlreturn
- nonamedreturns
- paralleltest
- scopelint
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@

* Refactored internal packages by `protogetter` linter issues

## v3.56.1
* Fixed fixenv usage (related to tests only)

## v3.56.0
* Fixed handle of operational errors in topic streams
* The minimum version of Go in `ydb-go-sdk` has been raised to `go1.21`
* Fixed topic writer infinite reconnections in some cases
* Refactored nil on err `internal/grpcwrapper/rawydb/issues.go`, when golangci-lint nilerr enabled
* Refactored nil on err `internal/grpcwrapper/rawtopic/describe_topic.go`, when golangci-lint nilerr enabled

## v3.55.3
* Fixed handle of operational errors in topic streams (backported fix only)

## v3.55.2
* Fixed init info in topic writer, when autoseq num turned off.

## v3.55.1
* Supported column name prefix `__discard_column_` for discard columns in result sets
* Made `StatusIds_SESSION_EXPIRED` retriable for idempotent operations


## v3.55.0
* Refactored `internal/value/intervalValue.Yql()`
* The minimum version of Go in `ydb-go-sdk` has been raised to `go1.20`
Expand Down
7 changes: 7 additions & 0 deletions balancers/balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (filterLocalDC) String() string {
func PreferLocalDC(balancer *balancerConfig.Config) *balancerConfig.Config {
balancer.Filter = filterLocalDC{}
balancer.DetectLocalDC = true

return balancer
}

Expand All @@ -49,6 +50,7 @@ func PreferLocalDC(balancer *balancerConfig.Config) *balancerConfig.Config {
func PreferLocalDCWithFallBack(balancer *balancerConfig.Config) *balancerConfig.Config {
balancer = PreferLocalDC(balancer)
balancer.AllowFallback = true

return balancer
}

Expand All @@ -61,6 +63,7 @@ func (locations filterLocations) Allow(_ balancerConfig.Info, c conn.Conn) bool
return true
}
}

return false
}

Expand Down Expand Up @@ -91,6 +94,7 @@ func PreferLocations(balancer *balancerConfig.Config, locations ...string) *bala
}
sort.Strings(locations)
balancer.Filter = filterLocations(locations)

return balancer
}

Expand All @@ -100,6 +104,7 @@ func PreferLocations(balancer *balancerConfig.Config, locations ...string) *bala
func PreferLocationsWithFallback(balancer *balancerConfig.Config, locations ...string) *balancerConfig.Config {
balancer = PreferLocations(balancer, locations...)
balancer.AllowFallback = true

return balancer
}

Expand Down Expand Up @@ -129,6 +134,7 @@ func Prefer(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool
balancer.Filter = filterFunc(func(_ balancerConfig.Info, c conn.Conn) bool {
return filter(c.Endpoint())
})

return balancer
}

Expand All @@ -138,6 +144,7 @@ func Prefer(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool
func PreferWithFallback(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool) *balancerConfig.Config {
balancer = Prefer(balancer, filter)
balancer.AllowFallback = true

return balancer
}

Expand Down
1 change: 1 addition & 0 deletions balancers/balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ func applyPreferFilter(info balancerConfig.Info, b *balancerConfig.Config, conns
res = append(res, c)
}
}

return res
}
3 changes: 3 additions & 0 deletions balancers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func CreateFromConfig(s string) (*balancerConfig.Config, error) {
if c.Fallback {
return PreferLocalDCWithFallBack(b), nil
}

return PreferLocalDC(b), nil
case preferTypeLocations:
if len(c.Locations) == 0 {
Expand All @@ -100,6 +101,7 @@ func CreateFromConfig(s string) (*balancerConfig.Config, error) {
if c.Fallback {
return PreferLocationsWithFallback(b, c.Locations...), nil
}

return PreferLocations(b, c.Locations...), nil
default:
return b, nil
Expand All @@ -125,6 +127,7 @@ func FromConfig(config string, opts ...fromConfigOption) *balancerConfig.Config
if h.errorHandler != nil {
h.errorHandler(err)
}

return h.fallbackBalancer
}

Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,6 @@ func (c *Config) With(opts ...Option) *Config {
c.trace,
c.metaOptions...,
)

return c
}
2 changes: 2 additions & 0 deletions config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func defaultGrpcOptions(t *trace.Driver, secure bool, tlsConfig *tls.Config) (op
insecure.NewCredentials(),
))
}

return opts
}

Expand All @@ -72,6 +73,7 @@ func certPool() *x509.CertPool {
if err == nil {
return certPool
}

return x509.NewCertPool()
}

Expand Down
3 changes: 3 additions & 0 deletions coordination/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func Example() {
db, err := ydb.Open(ctx, "grpc://localhost:2136/local")
if err != nil {
fmt.Printf("failed to connect: %v", err)

return
}
defer db.Close(ctx) // cleanup resources
Expand All @@ -28,12 +29,14 @@ func Example() {
})
if err != nil {
fmt.Printf("failed to create node: %v", err)

return
}
defer db.Coordination().DropNode(ctx, "/local/test")
e, c, err := db.Coordination().DescribeNode(ctx, "/local/test")
if err != nil {
fmt.Printf("failed to describe node: %v", err)

return
}
fmt.Printf("node description: %+v\nnode config: %+v\n", e, c)
Expand Down
4 changes: 4 additions & 0 deletions discovery/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ func Example_discoverCluster() {
db, err := ydb.Open(ctx, "grpc://localhost:2136/local")
if err != nil {
fmt.Printf("failed to connect: %v", err)

return
}
defer db.Close(ctx) // cleanup resources
endpoints, err := db.Discovery().Discover(ctx)
if err != nil {
fmt.Printf("discover failed: %v", err)

return
}
fmt.Printf("%s endpoints:\n", db.Name())
Expand All @@ -31,12 +33,14 @@ func Example_whoAmI() {
db, err := ydb.Open(ctx, "grpc://localhost:2136/local")
if err != nil {
fmt.Printf("failed to connect: %v", err)

return
}
defer db.Close(ctx) // cleanup resources
whoAmI, err := db.Discovery().WhoAmI(ctx)
if err != nil {
fmt.Printf("discover failed: %v", err)

return
}
fmt.Printf("%s whoAmI: %s\n", db.Name(), whoAmI.String())
Expand Down
1 change: 1 addition & 0 deletions driver_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ func (d *Driver) String() string {
fmt.Fprintf(buffer, ",Credentials:%v", c.String())
}
buffer.WriteByte('}')

return buffer.String()
}
4 changes: 2 additions & 2 deletions driver_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDriver_String(t *testing.T) {
config.WithDatabase("local"),
config.WithSecure(false),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:false,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:88)"}}`, //nolint:lll
s: `Driver{Endpoint:"localhost",Database:"local",Secure:false,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:90)"}}`, //nolint:lll
},
{
name: xtest.CurrentFileLine(),
Expand All @@ -32,7 +32,7 @@ func TestDriver_String(t *testing.T) {
config.WithDatabase("local"),
config.WithSecure(true),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:88)"}}`, //nolint:lll
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:90)"}}`, //nolint:lll
},
{
name: xtest.CurrentFileLine(),
Expand Down
1 change: 0 additions & 1 deletion examples/auth/environ/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"

environ "github.com/ydb-platform/ydb-go-sdk-auth-environ"

ydb "github.com/ydb-platform/ydb-go-sdk/v3"
)

Expand Down
3 changes: 1 addition & 2 deletions examples/auth/metadata_credentials/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"fmt"
"os"

yc "github.com/ydb-platform/ydb-go-yc"

ydb "github.com/ydb-platform/ydb-go-sdk/v3"
yc "github.com/ydb-platform/ydb-go-yc"
)

var dsn string
Expand Down
3 changes: 1 addition & 2 deletions examples/auth/service_account_credentials/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"fmt"
"os"

yc "github.com/ydb-platform/ydb-go-yc"

ydb "github.com/ydb-platform/ydb-go-sdk/v3"
yc "github.com/ydb-platform/ydb-go-yc"
)

var (
Expand Down
6 changes: 5 additions & 1 deletion examples/basic/database_sql/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/google/uuid"

"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
)

Expand All @@ -19,6 +18,7 @@ func seriesData(id string, released time.Time, title, info, comment string) type
} else {
commentv = types.OptionalValue(types.TextValue(comment))
}

return types.StructValue(
types.StructFieldValue("series_id", types.BytesValueFromString(id)),
types.StructFieldValue("release_date", types.DateValueFromTime(released)),
Expand Down Expand Up @@ -60,6 +60,7 @@ func getData() (series, seasons, episodes []types.Value) {
seasons = append(seasons, seasonsData...)
episodes = append(episodes, episodesData...)
}

return
}

Expand Down Expand Up @@ -115,6 +116,7 @@ func getDataForITCrowd(seriesID string) (series types.Value, seasons, episodes [
episodes = append(episodes, episodeData(seriesID, seasonID, uuid.New().String(), title, date))
}
}

return series, seasons, episodes
}

Expand Down Expand Up @@ -194,6 +196,7 @@ func getDataForSiliconValley(seriesID string) (series types.Value, seasons, epis
episodes = append(episodes, episodeData(seriesID, seasonID, uuid.New().String(), title, date))
}
}

return series, seasons, episodes
}

Expand All @@ -204,5 +207,6 @@ func date(date string) time.Time {
if err != nil {
panic(err)
}

return t
}
1 change: 0 additions & 1 deletion examples/basic/database_sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

environ "github.com/ydb-platform/ydb-go-sdk-auth-environ"

"github.com/ydb-platform/ydb-go-sdk/v3"
"github.com/ydb-platform/ydb-go-sdk/v3/sugar"
)
Expand Down
Loading

0 comments on commit 832da85

Please sign in to comment.