-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.go
73 lines (61 loc) · 1.54 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package prom2click
import (
"time"
"github.com/gotomicro/ego/core/elog"
)
// Option 可选项
type Option func(c *Container)
// WithHost 设置host
func WithHost(host string) Option {
return func(c *Container) {
c.config.Host = host
}
}
// WithPort 设置port
func WithPort(port int) Option {
return func(c *Container) {
c.config.Port = port
}
}
// WithNetwork 设置network
func WithNetwork(network string) Option {
return func(c *Container) {
c.config.Network = network
}
}
// WithTrustedPlatform 信任的Header头,获取客户端IP地址
func WithTrustedPlatform(trustedPlatform string) Option {
return func(c *Container) {
c.config.TrustedPlatform = trustedPlatform
}
}
// WithLogger 信任的Header头,获取客户端IP地址
func WithLogger(logger *elog.Component) Option {
return func(c *Container) {
c.logger = logger
}
}
// WithServerReadTimeout 设置超时时间
func WithServerReadTimeout(timeout time.Duration) Option {
return func(c *Container) {
c.config.ServerReadTimeout = timeout
}
}
// WithServerReadHeaderTimeout 设置超时时间
func WithServerReadHeaderTimeout(timeout time.Duration) Option {
return func(c *Container) {
c.config.ServerReadHeaderTimeout = timeout
}
}
// WithServerWriteTimeout 设置超时时间
func WithServerWriteTimeout(timeout time.Duration) Option {
return func(c *Container) {
c.config.ServerWriteTimeout = timeout
}
}
// WithContextTimeout 设置port
func WithContextTimeout(timeout time.Duration) Option {
return func(c *Container) {
c.config.ContextTimeout = timeout
}
}