@@ -47,6 +47,14 @@ type KeepaliveClientConfig struct {
47
47
PermitWithoutStream bool `mapstructure:"permit_without_stream"`
48
48
}
49
49
50
+ // NewDefaultKeepaliveClientConfig returns a new instance of KeepaliveClientConfig with default values.
51
+ func NewDefaultKeepaliveClientConfig () * KeepaliveClientConfig {
52
+ return & KeepaliveClientConfig {
53
+ Time : time .Second * 10 ,
54
+ Timeout : time .Second * 10 ,
55
+ }
56
+ }
57
+
50
58
// ClientConfig defines common settings for a gRPC client configuration.
51
59
type ClientConfig struct {
52
60
// The target to which the exporter is going to send traces or metrics,
@@ -91,12 +99,29 @@ type ClientConfig struct {
91
99
Auth * configauth.Authentication `mapstructure:"auth"`
92
100
}
93
101
102
+ // NewDefaultClientConfig returns a new instance of ClientConfig with default values.
103
+ func NewDefaultClientConfig () * ClientConfig {
104
+ return & ClientConfig {
105
+ TLSSetting : configtls .NewDefaultClientConfig (),
106
+ Keepalive : NewDefaultKeepaliveClientConfig (),
107
+ Auth : configauth .NewDefaultAuthentication (),
108
+ }
109
+ }
110
+
94
111
// KeepaliveServerConfig is the configuration for keepalive.
95
112
type KeepaliveServerConfig struct {
96
113
ServerParameters * KeepaliveServerParameters `mapstructure:"server_parameters"`
97
114
EnforcementPolicy * KeepaliveEnforcementPolicy `mapstructure:"enforcement_policy"`
98
115
}
99
116
117
+ // NewDefaultKeepaliveServerConfig returns a new instance of KeepaliveServerConfig with default values.
118
+ func NewDefaultKeepaliveServerConfig () * KeepaliveServerConfig {
119
+ return & KeepaliveServerConfig {
120
+ ServerParameters : NewDefaultKeepaliveServerParameters (),
121
+ EnforcementPolicy : NewDefaultKeepaliveEnforcementPolicy (),
122
+ }
123
+ }
124
+
100
125
// KeepaliveServerParameters allow configuration of the keepalive.ServerParameters.
101
126
// The same default values as keepalive.ServerParameters are applicable and get applied by the server.
102
127
// See https://godoc.org/google.golang.org/grpc/keepalive#ServerParameters for details.
@@ -108,6 +133,11 @@ type KeepaliveServerParameters struct {
108
133
Timeout time.Duration `mapstructure:"timeout"`
109
134
}
110
135
136
+ // NewDefaultKeepaliveServerParameters creates and returns a new instance of KeepaliveServerParameters with default settings.
137
+ func NewDefaultKeepaliveServerParameters () * KeepaliveServerParameters {
138
+ return & KeepaliveServerParameters {}
139
+ }
140
+
111
141
// KeepaliveEnforcementPolicy allow configuration of the keepalive.EnforcementPolicy.
112
142
// The same default values as keepalive.EnforcementPolicy are applicable and get applied by the server.
113
143
// See https://godoc.org/google.golang.org/grpc/keepalive#EnforcementPolicy for details.
@@ -116,6 +146,11 @@ type KeepaliveEnforcementPolicy struct {
116
146
PermitWithoutStream bool `mapstructure:"permit_without_stream"`
117
147
}
118
148
149
+ // NewDefaultKeepaliveEnforcementPolicy creates and returns a new instance of KeepaliveEnforcementPolicy with default settings.
150
+ func NewDefaultKeepaliveEnforcementPolicy () * KeepaliveEnforcementPolicy {
151
+ return & KeepaliveEnforcementPolicy {}
152
+ }
153
+
119
154
// ServerConfig defines common settings for a gRPC server configuration.
120
155
type ServerConfig struct {
121
156
// Server net.Addr config. For transport only "tcp" and "unix" are valid options.
@@ -151,6 +186,14 @@ type ServerConfig struct {
151
186
IncludeMetadata bool `mapstructure:"include_metadata"`
152
187
}
153
188
189
+ // NewDefaultServerConfig returns a new instance of ServerConfig with default values.
190
+ func NewDefaultServerConfig () * ServerConfig {
191
+ return & ServerConfig {
192
+ Keepalive : NewDefaultKeepaliveServerConfig (),
193
+ Auth : configauth .NewDefaultAuthentication (),
194
+ }
195
+ }
196
+
154
197
// sanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
155
198
func (gcs * ClientConfig ) sanitizedEndpoint () string {
156
199
switch {
0 commit comments