Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable godot #1118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ run:
# - ".*\\.my\\.go$"
# - lib/bad.go


# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
Expand All @@ -38,7 +37,6 @@ output:
# print linter name in the end of issue text, default is true
print-linter-name: true


# all available settings of specific linters
linters-settings:
errcheck:
Expand Down Expand Up @@ -179,7 +177,7 @@ linters-settings:
#
# The flag is passed to the ruleguard 'debug-group' argument.
# Default: ""
debug: 'emptyDecl'
debug: "emptyDecl"
# Deprecated, use 'failOn' param.
# If set to true, identical to failOn='all', otherwise failOn=''
failOnError: false
Expand Down Expand Up @@ -231,7 +229,6 @@ linters:
- funlen
- gochecknoglobals
- gocognit
- godot
- goerr113
- golint
- gomnd
Expand Down Expand Up @@ -308,4 +305,4 @@ issues:
# Examples: Type_PRIMITIVE_TYPE_ID_UNSPECIFIED, Ydb_Discovery_V1, _voidValue
- linters:
- nosnakecase
text : "(?:_[a-z]+(?:[A-Z](?:[a-z\\d]+|[A-Z\\d]+))+|(?:[A-Z][a-z\\d]+|[A-Z][A-Z\\d]+)+_(?:(?:[A-Z][a-z\\d]+|[A-Z\\d][A-Z\\d]+)_?)+)"
text: "(?:_[a-z]+(?:[A-Z](?:[a-z\\d]+|[A-Z\\d]+))+|(?:[A-Z][a-z\\d]+|[A-Z][A-Z\\d]+)+_(?:(?:[A-Z][a-z\\d]+|[A-Z\\d][A-Z\\d]+)_?)+)"
14 changes: 7 additions & 7 deletions balancers/balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring"
)

// Deprecated: RoundRobin is RandomChoice now
// Deprecated: RoundRobin is RandomChoice now.
func RoundRobin() *balancerConfig.Config {
return &balancerConfig.Config{}
}
Expand Down Expand Up @@ -46,7 +46,7 @@ func PreferLocalDC(balancer *balancerConfig.Config) *balancerConfig.Config {

// PreferLocalDCWithFallBack creates balancer which use endpoints only in location such as initial endpoint location
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead
// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead.
func PreferLocalDCWithFallBack(balancer *balancerConfig.Config) *balancerConfig.Config {
balancer = PreferLocalDC(balancer)
balancer.AllowFallback = true
Expand Down Expand Up @@ -84,7 +84,7 @@ func (locations filterLocations) String() string {
}

// PreferLocations creates balancer which use endpoints only in selected locations (such as "ABC", "DEF", etc.)
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location.
func PreferLocations(balancer *balancerConfig.Config, locations ...string) *balancerConfig.Config {
if len(locations) == 0 {
panic("empty list of locations")
Expand All @@ -100,7 +100,7 @@ func PreferLocations(balancer *balancerConfig.Config, locations ...string) *bala

// PreferLocationsWithFallback creates balancer which use endpoints only in selected locations
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead
// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead.
func PreferLocationsWithFallback(balancer *balancerConfig.Config, locations ...string) *balancerConfig.Config {
balancer = PreferLocations(balancer, locations...)
balancer.AllowFallback = true
Expand Down Expand Up @@ -129,7 +129,7 @@ func (p filterFunc) String() string {
}

// Prefer creates balancer which use endpoints by filter
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter.
func Prefer(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool) *balancerConfig.Config {
balancer.Filter = filterFunc(func(_ balancerConfig.Info, c conn.Conn) bool {
return filter(c.Endpoint())
Expand All @@ -140,15 +140,15 @@ func Prefer(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool

// PreferWithFallback creates balancer which use endpoints by filter
// Balancer "balancer" defines balancing algorithm between endpoints selected with filter
// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead
// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead.
func PreferWithFallback(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool) *balancerConfig.Config {
balancer = Prefer(balancer, filter)
balancer.AllowFallback = true

return balancer
}

// Default balancer used by default
// Default balancer used by default.
func Default() *balancerConfig.Config {
return RandomChoice()
}
28 changes: 14 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ func (c *Config) Credentials() credentials.Credentials {
return c.credentials
}

// ExcludeGRPCCodesForPessimization defines grpc codes for exclude its from pessimization trigger
// ExcludeGRPCCodesForPessimization defines grpc codes for exclude its from pessimization trigger.
func (c *Config) ExcludeGRPCCodesForPessimization() []grpcCodes.Code {
return c.excludeGRPCCodesForPessimization
}

// GrpcDialOptions reports about used grpc dialing options
// GrpcDialOptions reports about used grpc dialing options.
func (c *Config) GrpcDialOptions() []grpc.DialOption {
return append(
defaultGrpcOptions(c.trace, c.secure, c.tlsConfig),
c.grpcOptions...,
)
}

// Meta reports meta information about database connection
// Meta reports meta information about database connection.
func (c *Config) Meta() *meta.Meta {
return c.meta
}
Expand All @@ -64,17 +64,17 @@ func (c *Config) ConnectionTTL() time.Duration {
return c.connectionTTL
}

// Secure is a flag for secure connection
// Secure is a flag for secure connection.
func (c *Config) Secure() bool {
return c.secure
}

// Endpoint is a required starting endpoint for connect
// Endpoint is a required starting endpoint for connect.
func (c *Config) Endpoint() string {
return c.endpoint
}

// TLSConfig reports about TLS configuration
// TLSConfig reports about TLS configuration.
func (c *Config) TLSConfig() *tls.Config {
return c.tlsConfig
}
Expand Down Expand Up @@ -107,7 +107,7 @@ type Option func(c *Config)

// WithInternalDNSResolver
//
// Deprecated: always used internal dns-resolver
// Deprecated: always used internal dns-resolver.
func WithInternalDNSResolver() Option {
return func(c *Config) {}
}
Expand All @@ -133,7 +133,7 @@ func WithDatabase(database string) Option {
}
}

// WithCertificate appends certificate to TLS config root certificates
// WithCertificate appends certificate to TLS config root certificates.
func WithCertificate(certificate *x509.Certificate) Option {
return func(c *Config) {
c.tlsConfig.RootCAs.AddCert(certificate)
Expand All @@ -142,7 +142,7 @@ func WithCertificate(certificate *x509.Certificate) Option {

// WithTLSConfig replaces older TLS config
//
// Warning: all early changes of TLS config will be lost
// Warning: all early changes of TLS config will be lost.
func WithTLSConfig(tlsConfig *tls.Config) Option {
return func(c *Config) {
c.tlsConfig = tlsConfig
Expand Down Expand Up @@ -203,14 +203,14 @@ func WithOperationCancelAfter(operationCancelAfter time.Duration) Option {
}
}

// WithNoAutoRetry disable auto-retry calls from YDB sub-clients
// WithNoAutoRetry disable auto-retry calls from YDB sub-clients.
func WithNoAutoRetry() Option {
return func(c *Config) {
config.SetAutoRetry(&c.Common, false)
}
}

// WithPanicCallback applies panic callback to config
// WithPanicCallback applies panic callback to config.
func WithPanicCallback(panicCallback func(e interface{})) Option {
return func(c *Config) {
config.SetPanicCallback(&c.Common, panicCallback)
Expand Down Expand Up @@ -242,14 +242,14 @@ func WithMinTLSVersion(minVersion uint16) Option {
}
}

// WithTLSSInsecureSkipVerify applies InsecureSkipVerify flag to TLS config
// WithTLSSInsecureSkipVerify applies InsecureSkipVerify flag to TLS config.
func WithTLSSInsecureSkipVerify() Option {
return func(c *Config) {
c.tlsConfig.InsecureSkipVerify = true
}
}

// WithGrpcOptions appends custom grpc dial options to defaults
// WithGrpcOptions appends custom grpc dial options to defaults.
func WithGrpcOptions(option ...grpc.DialOption) Option {
return func(c *Config) {
c.grpcOptions = append(c.grpcOptions, option...)
Expand Down Expand Up @@ -279,7 +279,7 @@ func New(opts ...Option) *Config {
return c
}

// With makes copy of current Config with specified options
// With makes copy of current Config with specified options.
func (c *Config) With(opts ...Option) *Config {
for _, o := range opts {
if o != nil {
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
// DefaultKeepaliveInterval contains default duration between grpc keepalive
// DefaultKeepaliveInterval contains default duration between grpc keepalive.
DefaultKeepaliveInterval = 10 * time.Second
MinKeepaliveInterval = 10 * time.Second
DefaultDialTimeout = 5 * time.Second
Expand Down
8 changes: 4 additions & 4 deletions credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
)

// Credentials is an interface of YDB credentials required for connect with YDB
// Credentials is an interface of YDB credentials required for connect with YDB.
type Credentials interface {
// Token must return actual token or error
Token(ctx context.Context) (string, error)
}

// NewAccessTokenCredentials makes access token credentials object
// Passed options redefines default values of credentials object internal fields
// Passed options redefines default values of credentials object internal fields.
func NewAccessTokenCredentials(
accessToken string, opts ...credentials.AccessTokenCredentialsOption,
) *credentials.AccessToken {
return credentials.NewAccessTokenCredentials(accessToken, opts...)
}

// NewAnonymousCredentials makes anonymous credentials object
// Passed options redefines default values of credentials object internal fields
// Passed options redefines default values of credentials object internal fields.
func NewAnonymousCredentials(
opts ...credentials.AnonymousCredentialsOption,
) *credentials.Anonymous {
return credentials.NewAnonymousCredentials(opts...)
}

// NewStaticCredentials makes static credentials object
// NewStaticCredentials makes static credentials object.
func NewStaticCredentials(
user, password, authEndpoint string, opts ...credentials.StaticCredentialsOption,
) *credentials.Static {
Expand Down
4 changes: 2 additions & 2 deletions credentials/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
)

// WithSourceInfo option append to credentials object the source info for reporting source info details on error case
// WithSourceInfo option append to credentials object the source info for reporting source info details on error case.
func WithSourceInfo(sourceInfo string) credentials.SourceInfoOption {
return credentials.WithSourceInfo(sourceInfo)
}

// WithGrpcDialOptions option append to static credentials object GRPC dial options
// WithGrpcDialOptions option append to static credentials object GRPC dial options.
func WithGrpcDialOptions(opts ...grpc.DialOption) credentials.StaticCredentialsOption {
return credentials.WithGrpcDialOptions(opts...)
}
24 changes: 12 additions & 12 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (

var _ Connection = (*Driver)(nil)

// Driver type provide access to YDB service clients
// Driver type provide access to YDB service clients.
type Driver struct {
ctx context.Context // cancel while Driver.Close called.
ctxCancel context.CancelFunc
Expand Down Expand Up @@ -167,22 +167,22 @@ func (d *Driver) Close(ctx context.Context) (finalErr error) {
return nil
}

// Endpoint returns initial endpoint
// Endpoint returns initial endpoint.
func (d *Driver) Endpoint() string {
return d.config.Endpoint()
}

// Name returns database name
// Name returns database name.
func (d *Driver) Name() string {
return d.config.Database()
}

// Secure returns true if database Driver is secure
// Secure returns true if database Driver is secure.
func (d *Driver) Secure() bool {
return d.config.Secure()
}

// Table returns table client
// Table returns table client.
func (d *Driver) Table() table.Client {
return d.table
}
Expand All @@ -196,32 +196,32 @@ func (d *Driver) Query() query.Client {
return d.query
}

// Scheme returns scheme client
// Scheme returns scheme client.
func (d *Driver) Scheme() scheme.Client {
return d.scheme
}

// Coordination returns coordination client
// Coordination returns coordination client.
func (d *Driver) Coordination() coordination.Client {
return d.coordination
}

// Ratelimiter returns ratelimiter client
// Ratelimiter returns ratelimiter client.
func (d *Driver) Ratelimiter() ratelimiter.Client {
return d.ratelimiter
}

// Discovery returns discovery client
// Discovery returns discovery client.
func (d *Driver) Discovery() discovery.Client {
return d.discovery
}

// Scripting returns scripting client
// Scripting returns scripting client.
func (d *Driver) Scripting() scripting.Client {
return d.scripting
}

// Topic returns topic client
// Topic returns topic client.
func (d *Driver) Topic() topic.Client {
return d.topic
}
Expand Down Expand Up @@ -538,7 +538,7 @@ func (d *Driver) connect(ctx context.Context) (err error) {
// GRPCConn casts *ydb.Driver to grpc.ClientConnInterface for executing
// unary and streaming RPC over internal driver balancer.
//
// Warning: for connect to driver-unsupported YDB services
// Warning: for connect to driver-unsupported YDB services.
func GRPCConn(cc *Driver) grpc.ClientConnInterface {
return conn.WithContextModifier(cc.balancer, conn.WithoutWrapping)
}
2 changes: 1 addition & 1 deletion driver_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring"
)

// String returns string representation of Driver
// String returns string representation of Driver.
func (d *Driver) String() string {
buffer := xstring.Buffer()
defer buffer.Free()
Expand Down
Loading
Loading