/
options.go
49 lines (41 loc) · 1.04 KB
/
options.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
package sdk
import (
"net/http"
"time"
)
type rongCloudOption func(*RongCloud)
// WithRongCloudSMSURI 设置融云 SMS URI
func WithRongCloudSMSURI(rongCloudSMSURI string) rongCloudOption {
return func(o *RongCloud) {
o.rongCloudSMSURI = rongCloudSMSURI
}
}
// WithRongCloudURI 设置融云 URI
func WithRongCloudURI(rongCloudURI string) rongCloudOption {
return func(o *RongCloud) {
o.rongCloudURI = rongCloudURI
}
}
// WithTimeout 设置超时时间,最小单位为秒
func WithTimeout(t time.Duration) rongCloudOption {
return func(o *RongCloud) {
o.timeout = t
}
}
// WithKeepAlive 连接保活时间,最小单位为秒
func WithKeepAlive(t time.Duration) rongCloudOption {
return func(o *RongCloud) {
o.keepAlive = t
}
}
// WithMaxIdleConnsPerHost 设置每个域名最大连接数
func WithMaxIdleConnsPerHost(n int) rongCloudOption {
return func(o *RongCloud) {
o.maxIdleConnsPerHost = n
}
}
func WithTransport(transport http.RoundTripper) rongCloudOption {
return func(o *RongCloud) {
o.globalTransport = transport
}
}