Skip to content

Commit c5c8c21

Browse files
authored
Merge pull request #1680 from ydb-platform/defaults-to-const
move default constants fo internal, mark them deprecated
2 parents f2709fd + baa9c2a commit c5c8c21

File tree

3 files changed

+61
-13
lines changed

3 files changed

+61
-13
lines changed

config/defaults.go

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,58 @@ package config
33
import (
44
"crypto/tls"
55
"crypto/x509"
6-
"time"
76

87
"google.golang.org/grpc"
98
grpcCredentials "google.golang.org/grpc/credentials"
109
"google.golang.org/grpc/credentials/insecure"
11-
"google.golang.org/grpc/keepalive"
1210

1311
"github.com/ydb-platform/ydb-go-sdk/v3/balancers"
1412
"github.com/ydb-platform/ydb-go-sdk/v3/credentials"
13+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/config"
1514
"github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
1615
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
1716
)
1817

1918
var (
2019
// DefaultKeepaliveInterval contains default duration between grpc keepalive
21-
DefaultKeepaliveInterval = 10 * time.Second
22-
MinKeepaliveInterval = 10 * time.Second
23-
DefaultDialTimeout = 5 * time.Second
24-
DefaultGRPCMsgSize = 64 * 1024 * 1024 // 64MB
25-
DefaultGrpcConnectionPolicy = keepalive.ClientParameters{
26-
Time: DefaultKeepaliveInterval,
27-
Timeout: MinKeepaliveInterval,
28-
PermitWithoutStream: true,
29-
}
20+
//
21+
// Will be removed after Aug 2024.
22+
// Write Issue if you need the variable https://github.com/ydb-platform/ydb-go-sdk/issues/new/choose
23+
// Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
24+
DefaultKeepaliveInterval = config.DefaultKeepaliveInterval // 10 * time.Second
25+
26+
// MinKeepaliveInterval
27+
//
28+
// Will be removed after Aug 2024.
29+
// Write Issue if you need the variable https://github.com/ydb-platform/ydb-go-sdk/issues/new/choose
30+
// Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
31+
MinKeepaliveInterval = config.MinKeepaliveInterval // 10 * time.Second
32+
33+
// DefaultDialTimeout
34+
//
35+
// Will be removed after Aug 2024.
36+
// Write Issue if you need the variable https://github.com/ydb-platform/ydb-go-sdk/issues/new/choose
37+
// Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
38+
DefaultDialTimeout = config.DefaultDialTimeout // 5 * time.Second
39+
40+
// DefaultGRPCMsgSize
41+
//
42+
// Will be removed after Aug 2024.
43+
// Write Issue if you need the variable https://github.com/ydb-platform/ydb-go-sdk/issues/new/choose
44+
// Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
45+
DefaultGRPCMsgSize = config.DefaultGRPCMsgSize // 64 * 1024 * 1024 // 64MB
46+
47+
// DefaultGrpcConnectionPolicy
48+
//
49+
// Will be removed after Aug 2024.
50+
// Write Issue if you need the variable https://github.com/ydb-platform/ydb-go-sdk/issues/new/choose
51+
// Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
52+
DefaultGrpcConnectionPolicy = config.DefaultGrpcConnectionPolicy
53+
//DefaultGrpcConnectionPolicy = keepalive.ClientParameters{
54+
// Time: DefaultKeepaliveInterval,
55+
// Timeout: MinKeepaliveInterval,
56+
// PermitWithoutStream: true,
57+
//}
3058
)
3159

3260
func defaultGrpcOptions(secure bool, tlsConfig *tls.Config) (opts []grpc.DialOption) {

driver_string_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestDriver_String(t *testing.T) {
2323
config.WithDatabase("local"),
2424
config.WithSecure(false),
2525
)},
26-
s: `Driver{Endpoint:"localhost",Database:"local",Secure:false,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:80)"}}`, //nolint:lll
26+
s: `Driver{Endpoint:"localhost",Database:"local",Secure:false,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:108)"}}`, //nolint:lll
2727
},
2828
{
2929
name: xtest.CurrentFileLine(),
@@ -32,7 +32,7 @@ func TestDriver_String(t *testing.T) {
3232
config.WithDatabase("local"),
3333
config.WithSecure(true),
3434
)},
35-
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:80)"}}`, //nolint:lll
35+
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:108)"}}`, //nolint:lll
3636
},
3737
{
3838
name: xtest.CurrentFileLine(),

internal/config/defaults.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package config
2+
3+
import (
4+
"time"
5+
6+
"google.golang.org/grpc/keepalive"
7+
)
8+
9+
var (
10+
// DefaultKeepaliveInterval contains default duration between grpc keepalive
11+
DefaultKeepaliveInterval = 10 * time.Second
12+
MinKeepaliveInterval = 10 * time.Second
13+
DefaultDialTimeout = 5 * time.Second
14+
DefaultGRPCMsgSize = 64 * 1024 * 1024 // 64MB
15+
DefaultGrpcConnectionPolicy = keepalive.ClientParameters{
16+
Time: DefaultKeepaliveInterval,
17+
Timeout: MinKeepaliveInterval,
18+
PermitWithoutStream: true,
19+
}
20+
)

0 commit comments

Comments
 (0)