-
Notifications
You must be signed in to change notification settings - Fork 1
/
configuration.go
112 lines (90 loc) · 2.78 KB
/
configuration.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
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
package gosdk
import "github.com/oddin-gg/gosdk/protocols"
type configuration struct {
accessToken *string
defaultLocale protocols.Locale
maxInactivitySeconds int
maxRecoveryExecutionMinutes int
messagingPort int
sdkNodeID *int
selectedEnvironment *protocols.Environment
selectedRegion protocols.Region
reportExtendedData bool
forcedAPIURL string
forcedMQURL string
}
func (o configuration) ExchangeName() string {
return "oddinfeed"
}
func (o configuration) ReplayExchangeName() string {
return "oddinreplay"
}
func (o configuration) AccessToken() *string {
return o.accessToken
}
func (o configuration) DefaultLocale() protocols.Locale {
return o.defaultLocale
}
func (o configuration) MaxInactivitySeconds() int {
return o.maxInactivitySeconds
}
func (o configuration) MaxRecoveryExecutionMinutes() int {
return o.maxRecoveryExecutionMinutes
}
func (o configuration) MessagingPort() int {
return o.messagingPort
}
func (o configuration) SdkNodeID() *int {
return o.sdkNodeID
}
func (o configuration) SelectedEnvironment() *protocols.Environment {
return o.selectedEnvironment
}
func (o configuration) SelectedRegion() protocols.Region {
return o.selectedRegion
}
func (o configuration) SetRegion(region protocols.Region) protocols.OddsFeedConfiguration {
o.selectedRegion = region
return o
}
func (o configuration) ReportExtendedData() bool {
return o.reportExtendedData
}
func (o configuration) SetAPIURL(url string) protocols.OddsFeedConfiguration {
o.forcedAPIURL = url
return o
}
func (o configuration) SetMQURL(url string) protocols.OddsFeedConfiguration {
o.forcedMQURL = url
return o
}
func (o configuration) SetMessagingPort(port int) protocols.OddsFeedConfiguration {
o.messagingPort = port
return o
}
func (o configuration) APIURL() (string, error) {
if len(o.forcedAPIURL) == 0 {
return o.SelectedEnvironment().APIEndpoint(o.SelectedRegion())
}
return o.forcedAPIURL, nil
}
func (o configuration) MQURL() (string, error) {
if len(o.forcedMQURL) == 0 {
return o.SelectedEnvironment().MQEndpoint(o.SelectedRegion())
}
return o.forcedMQURL, nil
}
// NewConfiguration ...
func NewConfiguration(accessToken string, environment protocols.Environment, nodeID int, reportExtendedData bool) protocols.OddsFeedConfiguration {
return &configuration{
defaultLocale: protocols.EnLocale,
maxInactivitySeconds: 20,
maxRecoveryExecutionMinutes: 360,
messagingPort: 5672,
accessToken: &accessToken,
selectedEnvironment: &environment,
selectedRegion: protocols.DefaulRegion,
sdkNodeID: &nodeID,
reportExtendedData: reportExtendedData,
}
}