-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
125 lines (101 loc) · 2.87 KB
/
options.go
File metadata and controls
125 lines (101 loc) · 2.87 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package portal
import (
"fmt"
"time"
)
// NewPortalOptions returns the default portal settings as configured by this portal implementation.
func NewPortalOptions() *PortalOptions {
return &PortalOptions{
pollTimeOut: Rate(1000),
pollTimeIn: Rate(1000),
closeRetryCount: 3,
strictListen: false,
export: false,
log: false,
//TODO: Implement these options!
openTimeout: 5000 * time.Millisecond,
closeTimeout: 5000 * time.Millisecond,
}
}
func (opt *PortalOptions) String() (str string) {
str += fmt.Sprintf("Portal ID:\t\t%s\n", opt.id)
str += fmt.Sprintf("Poll Time Input:\t%s\n", opt.pollTimeIn)
str += fmt.Sprintf("Poll Time Output:\t%s\n", opt.pollTimeOut)
str += fmt.Sprintf("Open Timeout:\t\t%s\n", opt.openTimeout)
str += fmt.Sprintf("Close Timeout:\t\t%s\n", opt.closeTimeout)
str += fmt.Sprintf("Close Retry Count:\t%d\n", opt.closeRetryCount)
str += fmt.Sprintf("Strict Listen:\t\t%t\n", opt.strictListen)
str += fmt.Sprintf("Export:\t\t\t%t\n", opt.export)
str += opt.stringDebug()
return
}
/* ---
--- GETTERS ---
---
*/
func (opt *PortalOptions) GetID() string {
return opt.id
}
func (opt *PortalOptions) GetPollTimeIn() time.Duration {
return opt.pollTimeIn
}
func (opt *PortalOptions) GetPollTimePointerIn() *time.Duration {
return &opt.pollTimeIn
}
func (opt *PortalOptions) GetPollTimeOut() time.Duration {
return opt.pollTimeOut
}
func (opt *PortalOptions) GetPollTimePointerOut() *time.Duration {
return &opt.pollTimeOut
}
func (opt *PortalOptions) GetOpenTimeout() time.Duration {
return opt.openTimeout
}
func (opt *PortalOptions) GetCloseTimeout() time.Duration {
return opt.closeTimeout
}
func (opt *PortalOptions) GetCloseRetryCount() int {
return opt.closeRetryCount
}
func (opt *PortalOptions) GetStrictListen() bool {
return opt.strictListen
}
func (opt *PortalOptions) GetExport() bool {
return opt.export
}
/* ---
--- SETTERS ---
---
*/
func (opt *PortalOptions) SetID(id string) *PortalOptions {
opt.id = id
return opt
}
func (opt *PortalOptions) SetPollTimeIn(d time.Duration) *PortalOptions {
opt.pollTimeIn = d
return opt
}
func (opt *PortalOptions) SetPollTimeOut(d time.Duration) *PortalOptions {
opt.pollTimeOut = d
return opt
}
func (opt *PortalOptions) SetOpenTimeout(d time.Duration) *PortalOptions {
opt.openTimeout = d
return opt
}
func (opt *PortalOptions) SetCloseTimeout(d time.Duration) *PortalOptions {
opt.closeTimeout = d
return opt
}
func (opt *PortalOptions) SetCloseRetryCount(c int) *PortalOptions {
opt.closeRetryCount = c
return opt
}
func (opt *PortalOptions) SetStrictListen(strict bool) *PortalOptions {
opt.strictListen = strict
return opt
}
func (opt *PortalOptions) SetExport(export bool) *PortalOptions {
opt.export = export
return opt
}