-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
42 lines (34 loc) · 1014 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
40
41
42
package tcp
import (
"crypto/tls"
"net"
"go.unistack.org/micro/v3/server"
)
// DefaultMaxMsgSize define maximum message size that server can send
// or receive. Default value is 8K
var DefaultMaxMsgSize = 1024 * 8
type (
maxMsgSizeKey struct{}
tlsAuth struct{}
maxConnKey struct{}
netListener struct{}
)
//
// MaxMsgSize set the maximum message in bytes the server can receive and
// send. Default maximum message size is 8K
//
func MaxMsgSize(s int) server.Option {
return server.SetOption(maxMsgSizeKey{}, s)
}
// AuthTLS should be used to setup a secure authentication using TLS
func AuthTLS(t *tls.Config) server.Option {
return server.SetOption(tlsAuth{}, t)
}
// MaxConn specifies maximum number of max simultaneous connections to server
func MaxConn(n int) server.Option {
return server.SetOption(maxConnKey{}, n)
}
// Listener specifies the net.Listener to use instead of the default
func Listener(l net.Listener) server.Option {
return server.SetOption(netListener{}, l)
}