Files
open-im-server/internal/msggateway/options.go
T

37 lines
705 B
Go
Raw Normal View History

2023-03-08 18:39:18 +08:00
package msggateway
2023-02-14 21:08:36 +08:00
import "time"
type Option func(opt *configs)
type configs struct {
//长连接监听端口
port int
//长连接允许最大链接数
2023-02-16 16:32:31 +08:00
maxConnNum int64
2023-02-14 21:08:36 +08:00
//连接握手超时时间
handshakeTimeout time.Duration
//允许消息最大长度
messageMaxMsgLength int
}
func WithPort(port int) Option {
return func(opt *configs) {
opt.port = port
}
}
2023-02-16 16:32:31 +08:00
func WithMaxConnNum(num int64) Option {
2023-02-14 21:08:36 +08:00
return func(opt *configs) {
opt.maxConnNum = num
}
}
func WithHandshakeTimeout(t time.Duration) Option {
return func(opt *configs) {
opt.handshakeTimeout = t
}
}
func WithMessageMaxMsgLength(length int) Option {
return func(opt *configs) {
opt.messageMaxMsgLength = length
}
}