Documentation
¶
Overview ¶
Package global provides global variables and interfaces for accessing web and subscription servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetSubServer ¶
func SetSubServer(s SubServer)
SetSubServer sets the global subscription server instance.
func SetWebServer ¶
func SetWebServer(s WebServer)
SetWebServer sets the global web server instance.
Types ¶
type HashEntry ¶
type HashEntry struct {
Hash string // MD5 hash string
Value string // Original value
Timestamp time.Time // Time when the hash was created
}
HashEntry represents a stored hash entry with its value and timestamp.
type HashStorage ¶
type HashStorage struct {
sync.RWMutex
Data map[string]HashEntry // Map of hash to entry
Expiration time.Duration // Expiration duration for entries
}
HashStorage provides thread-safe storage for hash-value pairs with expiration.
func NewHashStorage ¶
func NewHashStorage(expiration time.Duration) *HashStorage
NewHashStorage creates a new HashStorage instance with the specified expiration duration.
func (*HashStorage) GetValue ¶
func (h *HashStorage) GetValue(hash string) (string, bool)
GetValue retrieves the original value for the given hash, returning true if found.
func (*HashStorage) IsMD5 ¶
func (h *HashStorage) IsMD5(hash string) bool
IsMD5 checks if the given string is a valid 32-character MD5 hash.
func (*HashStorage) RemoveExpiredHashes ¶
func (h *HashStorage) RemoveExpiredHashes()
RemoveExpiredHashes removes all hash entries that have exceeded the expiration duration.
func (*HashStorage) SaveHash ¶
func (h *HashStorage) SaveHash(query string) string
SaveHash generates an MD5 hash for the given query string and stores it with a timestamp.
type SubServer ¶
SubServer interface defines methods for accessing the subscription server instance.
func GetSubServer ¶
func GetSubServer() SubServer
GetSubServer returns the global subscription server instance.
type WebServer ¶
type WebServer interface {
GetCron() *cron.Cron // Get the cron scheduler
GetCtx() context.Context // Get the server context
GetWSHub() any // Get the WebSocket hub (using any to avoid circular dependency)
}
WebServer interface defines methods for accessing the web server instance.
func GetWebServer ¶
func GetWebServer() WebServer
GetWebServer returns the global web server instance.