global

package
v2.8.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

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) Reset

func (h *HashStorage) Reset()

Reset clears all stored hash entries.

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

type SubServer interface {
	GetCtx() context.Context // Get the server context
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL