feat(pool): 修改NewBadgerPool函数接受数据库路径参数并移除GetAllConnIDs方法
- 修改NewBadgerPool函数签名以接受badgerDir字符串参数 - 将默认数据库路径配置改为通过参数传入 - 移除GetAllConnIDs方法及其相关实现代码 - 更新TCPServer和WebSocket Manager构造函数以传递数据库路径 - 修复TCP服务器和WebSocket示例中的初始化调用
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ func Example() {
|
||||
}
|
||||
|
||||
// 创建TCP服务器
|
||||
server, err := NewTCPServer("0.0.0.0:8888", config)
|
||||
server, err := NewTCPServer("0.0.0.0:8888", config, "./badger/tcp")
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to create server: %v\n", err)
|
||||
return
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ type ConnectionPool struct {
|
||||
}
|
||||
|
||||
// NewTCPServer 创建一个新的TCP服务器
|
||||
func NewTCPServer(address string, config *TcpPoolConfig) (*TCPServer, error) {
|
||||
func NewTCPServer(address string, config *TcpPoolConfig, dbPath string) (*TCPServer, error) {
|
||||
logger := g.Log(address)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
// 初始化BadgerDB连接池
|
||||
badgerPool, err := pool.NewBadgerPool()
|
||||
badgerPool, err := pool.NewBadgerPool(dbPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create badger pool: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user