2023-02-09 19:18:06 +00:00
|
|
|
package global
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
_ "unsafe"
|
2023-04-27 20:45:06 +00:00
|
|
|
|
|
|
|
"github.com/robfig/cron/v3"
|
2024-12-12 22:43:33 +00:00
|
|
|
"github.com/patrickmn/go-cache"
|
2023-02-09 19:18:06 +00:00
|
|
|
)
|
|
|
|
|
2024-03-10 21:31:24 +00:00
|
|
|
var (
|
|
|
|
webServer WebServer
|
|
|
|
subServer SubServer
|
2024-12-12 22:43:33 +00:00
|
|
|
caching Cache
|
2024-03-10 21:31:24 +00:00
|
|
|
)
|
2023-02-09 19:18:06 +00:00
|
|
|
|
|
|
|
type WebServer interface {
|
|
|
|
GetCron() *cron.Cron
|
|
|
|
GetCtx() context.Context
|
|
|
|
}
|
|
|
|
|
2023-05-22 14:36:34 +00:00
|
|
|
type SubServer interface {
|
|
|
|
GetCtx() context.Context
|
|
|
|
}
|
|
|
|
|
2024-12-12 22:43:33 +00:00
|
|
|
type Cache interface {
|
|
|
|
Memory() *cache.Cache
|
|
|
|
GetCtx() context.Context
|
|
|
|
}
|
|
|
|
|
2023-02-09 19:18:06 +00:00
|
|
|
func SetWebServer(s WebServer) {
|
|
|
|
webServer = s
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetWebServer() WebServer {
|
|
|
|
return webServer
|
|
|
|
}
|
2023-05-22 14:36:34 +00:00
|
|
|
|
|
|
|
func SetSubServer(s SubServer) {
|
|
|
|
subServer = s
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetSubServer() SubServer {
|
|
|
|
return subServer
|
|
|
|
}
|
2024-12-12 22:43:33 +00:00
|
|
|
|
|
|
|
func SetCache(c Cache) {
|
|
|
|
caching = c
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetCache() Cache {
|
|
|
|
return caching
|
|
|
|
}
|