Files
trihuy-russian/web/global/global.go
T

46 lines
1.0 KiB
Go
Raw Normal View History

2025-09-20 09:35:50 +02:00
// Package global provides global variables and interfaces for accessing web and subscription servers.
2023-02-09 22:48:06 +03:30
package global
import (
"context"
_ "unsafe"
2023-04-28 00:15:06 +03:30
"github.com/robfig/cron/v3"
2023-02-09 22:48:06 +03:30
)
2024-03-11 01:01:24 +03:30
var (
webServer WebServer
subServer SubServer
)
2023-02-09 22:48:06 +03:30
2025-09-20 09:35:50 +02:00
// WebServer interface defines methods for accessing the web server instance.
2023-02-09 22:48:06 +03:30
type WebServer interface {
2025-09-20 09:35:50 +02:00
GetCron() *cron.Cron // Get the cron scheduler
GetCtx() context.Context // Get the server context
2023-02-09 22:48:06 +03:30
}
2025-09-20 09:35:50 +02:00
// SubServer interface defines methods for accessing the subscription server instance.
2023-05-22 18:06:34 +03:30
type SubServer interface {
2025-09-20 09:35:50 +02:00
GetCtx() context.Context // Get the server context
2023-05-22 18:06:34 +03:30
}
2025-09-20 09:35:50 +02:00
// SetWebServer sets the global web server instance.
2023-02-09 22:48:06 +03:30
func SetWebServer(s WebServer) {
webServer = s
}
2025-09-20 09:35:50 +02:00
// GetWebServer returns the global web server instance.
2023-02-09 22:48:06 +03:30
func GetWebServer() WebServer {
return webServer
}
2023-05-22 18:06:34 +03:30
2025-09-20 09:35:50 +02:00
// SetSubServer sets the global subscription server instance.
2023-05-22 18:06:34 +03:30
func SetSubServer(s SubServer) {
subServer = s
}
2025-09-20 09:35:50 +02:00
// GetSubServer returns the global subscription server instance.
2023-05-22 18:06:34 +03:30
func GetSubServer() SubServer {
return subServer
}