Skip to content

Commit

Permalink
refactor: server 移除 WithConnMessageChannelSize 可选项
Browse files Browse the repository at this point in the history
  • Loading branch information
kercylan98 committed Sep 19, 2023
1 parent 1bc32e2 commit 31c0e1b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 16 deletions.
1 change: 0 additions & 1 deletion server/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
DefaultMessageBufferSize = 1024
DefaultAsyncPoolSize = 256
DefaultWebsocketReadDeadline = 30 * time.Second
DefaultConnectionChannelSize = 1024 * 10
)

const (
Expand Down
13 changes: 0 additions & 13 deletions server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,6 @@ type runtime struct {
websocketCompression int // websocket压缩等级
websocketWriteCompression bool // websocket写入压缩
limitLife time.Duration // 限制最大生命周期
connMessageChannelSize int // 连接消息通道大小
}

// WithConnMessageChannelSize 通过指定连接消息通道大小的方式创建服务器
// - 足够大的消息通道可以确保连接在写入消息时不至于阻塞
// - 默认值为 DefaultConnectionChannelSize
func WithConnMessageChannelSize(size int) Option {
return func(srv *Server) {
if size <= 0 {
size = DefaultConnectionChannelSize
}
srv.connMessageChannelSize = size
}
}

// WithLimitLife 通过限制最大生命周期的方式创建服务器
Expand Down
3 changes: 1 addition & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import (
func New(network Network, options ...Option) *Server {
server := &Server{
runtime: &runtime{
messagePoolSize: DefaultMessageBufferSize,
connMessageChannelSize: DefaultConnectionChannelSize,
messagePoolSize: DefaultMessageBufferSize,
},
option: &option{},
network: network,
Expand Down

0 comments on commit 31c0e1b

Please sign in to comment.