Files
ProjectOctopus/agent-go/g/global.go
2024-03-28 15:13:56 +08:00

48 lines
902 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 (
"github.com/panjf2000/ants/v2"
"github.com/spf13/viper"
"wdd.io/agent-common/logger"
)
type Global struct {
AgentHasRegister bool
AgentConfig *viper.Viper
P *ants.Pool
}
const (
QueueDirect = "direct"
QueueTopic = "topic"
ExecOmType = "EXECUTOR"
StatusOmType = "STATUS"
InitOmType = "INIT"
AgentOmType = "AGENT"
BaseFuncOssUrlPrefix = "https://b2.107421.xyz/"
)
// 创建协程池子
var pool, _ = ants.NewPool(
20,
ants.WithNonblocking(false),
ants.WithLogger(logger.Log),
ants.WithMaxBlockingTasks(10),
ants.WithDisablePurge(true),
ants.WithPreAlloc(true),
)
var G = NewGlobal(
pool,
)
// NewGlobal NewGlobal构造函数返回一个新的Global实例其中包含指定的Logger。
func NewGlobal(pool *ants.Pool) *Global {
return &Global{
AgentHasRegister: false,
AgentConfig: nil,
P: pool,
}
}