-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
53 lines (43 loc) · 1.6 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
package mqtt
import "time"
const (
DefaultKeepAlive = 60 * time.Second
DefaultConnectTimeout = 2 * time.Second
DefaultAckTimeout = 20 * time.Second
DefaultTimeoutRetries = 3
DefaultSessionsProvider = "mem"
DefaultAuthenticator = "mockSuccess"
DefaultTopicsProvider = "mem"
)
type Options struct {
// The number of seconds to keep the connection live if there's no data.
// If not set then default to 5 mins.
KeepAlive time.Duration
// The number of seconds to wait for the CONNECT message before disconnecting.
// If not set then default to 2 seconds.
ConnectTimeout time.Duration
// The number of seconds to wait for any ACK messages before failing.
// If not set then default to 20 seconds.
AckTimeout time.Duration
// The number of times to retry sending a packet if ACK is not received.
// If no set then default to 3 retries.
TimeoutRetries int
// Authenticator is the authenticator used to check username and password sent
// in the CONNECT message. If not set then default to "mockSuccess".
Authenticator string
// SessionsProvider is the session store that keeps all the Session objects.
// This is the store to check if CleanSession is set to 0 in the CONNECT message.
// If not set then default to "mem".
SessionsProvider string
// TopicsProvider is the topic store that keeps all the subscription topics.
// If not set then default to "mem".
TopicsProvider string
}
func NewOptions() *Options {
return &Options{
KeepAlive: DefaultKeepAlive,
ConnectTimeout: DefaultConnectTimeout,
AckTimeout: DefaultAckTimeout,
TimeoutRetries: DefaultTimeoutRetries,
}
}