feat 默认模块
This commit is contained in:
@@ -9,12 +9,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const serviceConfig = `{
|
||||
"loadBalancingConfig": [
|
||||
{
|
||||
"round_robin": {}
|
||||
}
|
||||
],
|
||||
"healthCheckConfig": {
|
||||
"serviceName": ""
|
||||
}
|
||||
}`
|
||||
|
||||
func NewGrpcConnection(target string) (*grpc.ClientConn, error) {
|
||||
cc, err := grpc.NewClient(
|
||||
target,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
|
||||
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin": {}}]}`),
|
||||
grpc.WithDefaultServiceConfig(serviceConfig),
|
||||
grpc.WithKeepaliveParams(
|
||||
keepalive.ClientParameters{
|
||||
Time: 30 * time.Second, // 保活探测包发送的时间间隔
|
||||
|
||||
Reference in New Issue
Block a user