-
Notifications
You must be signed in to change notification settings - Fork 8
/
option.go
41 lines (34 loc) · 951 Bytes
/
option.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
package rcon
import "time"
// Settings contains option to Conn.
type Settings struct {
dialTimeout time.Duration
deadline time.Duration
maxCommandLen int
}
// DefaultSettings provides default deadline settings to Conn.
var DefaultSettings = Settings{
dialTimeout: DefaultDialTimeout,
deadline: DefaultDeadline,
maxCommandLen: DefaultMaxCommandLen,
}
// Option allows to inject settings to Settings.
type Option func(s *Settings)
// SetDialTimeout injects dial Timeout to Settings.
func SetDialTimeout(timeout time.Duration) Option {
return func(s *Settings) {
s.dialTimeout = timeout
}
}
// SetDeadline injects read/write Timeout to Settings.
func SetDeadline(timeout time.Duration) Option {
return func(s *Settings) {
s.deadline = timeout
}
}
// SetMaxCommandLen injects maxCommandLen to Settings.
func SetMaxCommandLen(maxCommandLen int) Option {
return func(s *Settings) {
s.maxCommandLen = maxCommandLen
}
}