-
Notifications
You must be signed in to change notification settings - Fork 11
/
options.go
39 lines (33 loc) · 990 Bytes
/
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
package sessionreducer
type options struct {
sockAddr string
maxMessageSize int
serverInfoFilePath string
}
// Option is the interface to apply options.
type Option func(*options)
func defaultOptions() *options {
return &options{
sockAddr: address,
maxMessageSize: defaultMaxMessageSize,
serverInfoFilePath: serverInfoFilePath,
}
}
// WithMaxMessageSize sets the server max receive message size and the server max send message size to the given size.
func WithMaxMessageSize(size int) Option {
return func(opts *options) {
opts.maxMessageSize = size
}
}
// WithSockAddr start the server with the given sock addr. This is mainly used for testing purposes.
func WithSockAddr(addr string) Option {
return func(opts *options) {
opts.sockAddr = addr
}
}
// WithServerInfoFilePath sets the server info file path to the given path.
func WithServerInfoFilePath(f string) Option {
return func(opts *options) {
opts.serverInfoFilePath = f
}
}