-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconf.go
69 lines (64 loc) · 1.8 KB
/
conf.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
package jenkinsapi
import (
"log"
"os"
"time"
)
type HTTPTimeout struct {
ConnectTimeout time.Duration
ReadWriteTimeout time.Duration
HeaderTimeout time.Duration
LongTimeout time.Duration
IdleConnTimeout time.Duration
}
type HTTPMaxConns struct {
MaxIdleConns int
MaxIdleConnsPerHost int
}
type Config struct {
Endpoint string
User string
ApiToken string
RetryTimes uint // Retry count by default it's 5.
UserAgent string // SDK name/version/system information
IsDebug bool // Enable debug mode. Default is false.
Timeout uint // Timeout in seconds. By default it's 60.
IsCname bool // If cname is in the endpoint.
HTTPTimeout HTTPTimeout // HTTP timeout
HTTPMaxConns HTTPMaxConns // Http max connections
IsUseProxy bool // Flag of using proxy.
ProxyHost string // Flag of using proxy host.
IsAuthProxy bool // Flag of needing authentication.
ProxyUser string // Proxy user
ProxyPassword string // Proxy password
Logger *log.Logger // For write log
}
func getDefaultConf() *Config {
return &Config{
Endpoint: "",
User: "",
ApiToken: "",
RetryTimes: 5,
UserAgent: userAgent(),
IsDebug: false,
Timeout: 60,
IsCname: false,
HTTPTimeout: HTTPTimeout{
ConnectTimeout: time.Second * 30,
ReadWriteTimeout: time.Second * 60,
HeaderTimeout: time.Second * 60,
LongTimeout: time.Second * 300,
IdleConnTimeout: time.Second * 60,
},
HTTPMaxConns: HTTPMaxConns{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
},
IsUseProxy: false,
ProxyHost: "",
IsAuthProxy: false,
ProxyUser: "",
ProxyPassword: "",
Logger: log.New(os.Stdout, "", log.LstdFlags),
}
}