Files
ProjectOctopus/agent-go/g/global.go
2023-06-16 14:22:58 +08:00

38 lines
795 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 (
logger2 "agent-go/logger"
"github.com/panjf2000/ants/v2"
"github.com/spf13/viper"
)
type Global struct {
AgentHasRegister bool
AgentConfig *viper.Viper
P *ants.Pool
}
const (
QueueDirect = "direct"
QueueTopic = "topic"
ExecOmType = "EXECUTOR"
StatusOmType = "STATUS"
InitOmType = "INIT"
AgentOmType = "AGENT"
)
var pool, _ = ants.NewPool(100, ants.WithNonblocking(false), ants.WithLogger(logger2.Log), ants.WithMaxBlockingTasks(30), ants.WithDisablePurge(true))
var G = NewGlobal(
pool,
)
// NewGlobal NewGlobal构造函数返回一个新的Global实例其中包含指定的Logger。
func NewGlobal(pool *ants.Pool) *Global {
return &Global{
AgentHasRegister: false,
AgentConfig: nil,
P: pool,
}
}