[agent-go] 调整代码结构

This commit is contained in:
zeaslity
2023-03-30 14:26:11 +08:00
parent b01eb57ee5
commit 124143c6c6
17 changed files with 622 additions and 594 deletions

View File

@@ -1,16 +1,15 @@
package g
import (
"agent-go/config"
logger2 "agent-go/logger"
"github.com/panjf2000/ants/v2"
"github.com/spf13/viper"
)
type Global struct {
LOG *Logger
NacosConfig *viper.Viper
AgentServerInfo *config.AgentServerInfo
P *ants.Pool
AgentHasRegister bool
NacosConfig *viper.Viper
P *ants.Pool
}
const (
@@ -21,21 +20,17 @@ const (
InitOmType = "INIT"
)
var logger, _ = NewLogger()
var pool, _ = ants.NewPool(100, ants.WithNonblocking(true), ants.WithLogger(logger))
var pool, _ = ants.NewPool(100, ants.WithNonblocking(true), ants.WithLogger(logger2.Log))
var G = NewGlobal(
logger,
pool,
)
// NewGlobal NewGlobal构造函数返回一个新的Global实例其中包含指定的Logger。
func NewGlobal(logger *Logger, pool *ants.Pool) *Global {
func NewGlobal(pool *ants.Pool) *Global {
return &Global{
LOG: logger,
NacosConfig: nil,
AgentServerInfo: nil,
P: pool,
AgentHasRegister: false,
NacosConfig: nil,
P: pool,
}
}