Files
ProjectOctopus/agent-go/g/global.go
2023-03-28 13:47:04 +08:00

42 lines
814 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package g
import (
"agent-go/config"
"github.com/panjf2000/ants/v2"
"github.com/spf13/viper"
)
type Global struct {
LOG *Logger
NacosConfig *viper.Viper
AgentServerInfo *config.AgentServerInfo
P *ants.Pool
}
const (
QueueDirect = "direct"
QueueTopic = "topic"
ExecOmType = "EXECUTOR"
StatusOmType = "STATUS"
InitOmType = "INIT"
)
var logger, _ = NewLogger()
var pool, _ = ants.NewPool(100, ants.WithNonblocking(true), ants.WithLogger(logger))
var G = NewGlobal(
logger,
pool,
)
// NewGlobal NewGlobal构造函数返回一个新的Global实例其中包含指定的Logger。
func NewGlobal(logger *Logger, pool *ants.Pool) *Global {
return &Global{
LOG: logger,
NacosConfig: nil,
AgentServerInfo: nil,
P: pool,
}
}