/
transport.go
57 lines (51 loc) · 2.36 KB
/
transport.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
//
// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt )
//
// 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
//
// https://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 config providers configuration type and load configuration logic
package config
// TCP represent the TCP configuration for server.
type Transport struct {
RoundTripper *RoundTripper `yaml:"round_tripper" json:"round_tripper"`
Backoff *Backoff `yaml:"backoff" json:"backoff"`
}
type RoundTripper struct {
TLSHandshakeTimeout string `yaml:"tls_handshake_timeout" json:"tls_handshake_timeout"`
MaxIdleConns int `yaml:"max_idle_conns" json:"max_idle_conns"`
MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host" json:"max_idle_conns_per_host"`
MaxConnsPerHost int `yaml:"max_conns_per_host" json:"max_conns_per_host"`
IdleConnTimeout string `yaml:"idle_conn_timeout" json:"idle_conn_timeout"`
ResponseHeaderTimeout string `yaml:"response_header_timeout" json:"response_header_timeout"`
ExpectContinueTimeout string `yaml:"expect_continue_timeout" json:"expect_continue_timeout"`
MaxResponseHeaderSize int64 `yaml:"max_response_header_size" json:"max_response_header_size"`
WriteBufferSize int64 `yaml:"write_buffer_size" json:"write_buffer_size"`
ReadBufferSize int64 `yaml:"read_buffer_size" json:"read_buffer_size"`
ForceAttemptHTTP2 bool `yaml:"force_attempt_http_2" json:"force_attempt_http_2"`
}
func (r *RoundTripper) Bind() *RoundTripper {
r.TLSHandshakeTimeout = GetActualValue(r.TLSHandshakeTimeout)
r.IdleConnTimeout = GetActualValue(r.IdleConnTimeout)
r.ResponseHeaderTimeout = GetActualValue(r.ResponseHeaderTimeout)
r.ExpectContinueTimeout = GetActualValue(r.ExpectContinueTimeout)
return r
}
func (t *Transport) Bind() *Transport {
if t.RoundTripper != nil {
t.RoundTripper = t.RoundTripper.Bind()
}
if t.Backoff != nil {
t.Backoff = t.Backoff.Bind()
}
return t
}