-
Notifications
You must be signed in to change notification settings - Fork 817
/
grpc_option.go
74 lines (63 loc) · 3.02 KB
/
grpc_option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright 2023 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package streamclient
import (
"crypto/tls"
"github.com/cloudwego/kitex/client"
"github.com/cloudwego/kitex/pkg/remote/trans/nphttp2/grpc"
)
// WithGRPCConnPoolSize sets the value for the client connection pool size.
func WithGRPCConnPoolSize(s uint32) Option {
return ConvertOptionFrom(client.WithGRPCConnPoolSize(s))
}
// WithGRPCWriteBufferSize determines how much data can be batched before writing
// on the wire. The corresponding memory allocation for this buffer will be twice
// the size to keep syscalls low. The default value for this buffer is 32KB.
func WithGRPCWriteBufferSize(s uint32) Option {
return ConvertOptionFrom(client.WithGRPCWriteBufferSize(s))
}
// WithGRPCReadBufferSize lets you set the size of read buffer, this determines how
// much data can be read at most for each read syscall.
func WithGRPCReadBufferSize(s uint32) Option {
return ConvertOptionFrom(client.WithGRPCReadBufferSize(s))
}
// WithGRPCInitialWindowSize sets the value for initial window size on a grpc stream.
// The lower bound for window size is 64K and any value smaller than that will be ignored.
// It corresponds to the WithInitialWindowSize DialOption of gRPC.
func WithGRPCInitialWindowSize(s uint32) Option {
return ConvertOptionFrom(client.WithGRPCInitialWindowSize(s))
}
// WithGRPCInitialConnWindowSize sets the value for initial window size on a connection of grpc.
// The lower bound for window size is 64K and any value smaller than that will be ignored.
// It corresponds to the WithInitialConnWindowSize DialOption of gRPC.
func WithGRPCInitialConnWindowSize(s uint32) Option {
return ConvertOptionFrom(client.WithGRPCInitialConnWindowSize(s))
}
// WithGRPCMaxHeaderListSize returns a DialOption that specifies the maximum
// (uncompressed) size of header list that the client is prepared to accept.
// It corresponds to the WithMaxHeaderListSize DialOption of gRPC.
func WithGRPCMaxHeaderListSize(s uint32) Option {
return ConvertOptionFrom(client.WithGRPCMaxHeaderListSize(s))
}
// WithGRPCKeepaliveParams returns a DialOption that specifies keepalive parameters for the
// client transport. It corresponds to the WithKeepaliveParams DialOption of gRPC.
func WithGRPCKeepaliveParams(kp grpc.ClientKeepalive) Option {
return ConvertOptionFrom(client.WithGRPCKeepaliveParams(kp))
}
// WithGRPCTLSConfig sets the TLS config for gRPC client.
func WithGRPCTLSConfig(tlsConfig *tls.Config) Option {
return ConvertOptionFrom(client.WithGRPCTLSConfig(tlsConfig))
}