支持注入连接管理实例
This commit is contained in:
parent
551da36ac9
commit
88112bc2d0
@ -9,6 +9,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-developer/gopkg/logger"
|
"github.com/go-developer/gopkg/logger"
|
||||||
|
"github.com/go-developer/websocket/storage"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ type WSServerConfig struct {
|
|||||||
LogLevel zapcore.Level // 日志等级
|
LogLevel zapcore.Level // 日志等级
|
||||||
LogSplitInterval logger.TimeIntervalType // 日至切割的时间间隔
|
LogSplitInterval logger.TimeIntervalType // 日至切割的时间间隔
|
||||||
StoreConnection bool // 存储连接
|
StoreConnection bool // 存储连接
|
||||||
|
ConnectionManager storage.IConnection // 连接管理实例
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWSServerConfig 设置WS-Server的配置
|
// SetWSServerConfig 设置WS-Server的配置
|
||||||
@ -117,6 +119,7 @@ func NewWSServerConfig(optionList ...SetWSServerConfig) *WSServerConfig {
|
|||||||
LogLevel: DefaultLogLevel,
|
LogLevel: DefaultLogLevel,
|
||||||
LogSplitInterval: DefaultLogSplitInterval,
|
LogSplitInterval: DefaultLogSplitInterval,
|
||||||
StoreConnection: DefaultStoreConnection,
|
StoreConnection: DefaultStoreConnection,
|
||||||
|
ConnectionManager: storage.NewDefaultConnectionManager(),
|
||||||
}
|
}
|
||||||
for _, o := range optionList {
|
for _, o := range optionList {
|
||||||
o(c)
|
o(c)
|
||||||
|
@ -12,15 +12,15 @@ import (
|
|||||||
"github.com/go-developer/websocket/context"
|
"github.com/go-developer/websocket/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// NewDefaultConnectionManager 默认的内存连接管理实例
|
||||||
// Connection 连接管理
|
//
|
||||||
Connection IConnection
|
// Author : go_developer@163.com<张德满>
|
||||||
)
|
//
|
||||||
|
// Date : 11:32 下午 2021/4/17
|
||||||
func init() {
|
func NewDefaultConnectionManager() IConnection {
|
||||||
c := &connection{}
|
c := &connection{}
|
||||||
c.table, _ = easymap.NewSegment(4096, true)
|
c.table, _ = easymap.NewSegment(4096, true)
|
||||||
Connection = c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
type connection struct {
|
type connection struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user