worker

package
v0.0.0-...-4bcff6b Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertsWorker

func AlertsWorker(db *sql.DB)

func AutomationWorker

func AutomationWorker(db *sql.DB)

AutomationWorker tracks peer handshakes and fires webhooks on state change

func DDNSWorker

func DDNSWorker(db *sql.DB)

DDNSWorker runs the DDNS update loop with production-grade safeguards

func EnableDDNS

func EnableDDNS()

EnableDDNS resets failure counter and re-enables worker

func ExpiryWorker

func ExpiryWorker(db *sql.DB)

ExpiryWorker checks for expired peers and disables them

func ForceUpdate

func ForceUpdate(db *sql.DB) error

ForceUpdate allows manual DDNS update via API

func GetBackoffDuration

func GetBackoffDuration(failures int) time.Duration

GetBackoffDuration returns exponential backoff duration

func GetDDNSStatus

func GetDDNSStatus() map[string]interface{}

GetDDNSStatus returns current DDNS status for monitoring

func LimitWorker

func LimitWorker(db *sql.DB)

LimitWorker checks for peers exceeding data limits and disables them Runs frequently (every 10 seconds) for fast enforcement

func MonitorWorker

func MonitorWorker(db *sql.DB)

func NotificationWorker

func NotificationWorker(db *sql.DB)

NotificationWorker sends alerts to Telegram/Discord

func QueueNotification

func QueueNotification(db *sql.DB, channel, webhookURL, message string) error

QueueNotification adds a notification to the queue

func RedactURL

func RedactURL(input string) string

RedactURL scrubs sensitive tokens from URL strings for safe logging

func ScheduleWorker

func ScheduleWorker(db *sql.DB)

ScheduleWorker enables/disables peers based on time schedules

func SelfHealingWorker

func SelfHealingWorker(db *sql.DB)

SelfHealingWorker monitors system health and auto-recovers failed components

func StatsWorker

func StatsWorker()

StatsWorker collects system metrics every second

func Trigger

func Trigger()

Trigger signals reconciliation (placeholder - uses the existing reconcile.Trigger pattern)

Types

type DDNSConfig

type DDNSConfig struct {
	Provider   string `json:"provider"`
	Domain     string `json:"domain"`
	Token      string `json:"token"`
	WebhookURL string `json:"webhook_url"`
	TTL        int    `json:"ttl"`
	Interval   int    `json:"interval_minutes"` // Configurable check interval
}

DDNSConfig holds provider-specific configuration

type DDNSError

type DDNSError struct {
	Message    string
	Persistent bool // If true, increment failure counter; if false, transient
}

DDNSError for custom error handling with persistence flag

func (*DDNSError) Error

func (e *DDNSError) Error() string

type SystemStats

type SystemStats struct {
	CPUPercent    float64 `json:"cpu_percent"`
	RAMPercent    float64 `json:"ram_percent"`
	RAMUsedMB     int64   `json:"ram_used_mb"`
	RAMTotalMB    int64   `json:"ram_total_mb"`
	NetworkRX     int64   `json:"network_rx_bps"`
	NetworkTX     int64   `json:"network_tx_bps"`
	CPUTempC      float64 `json:"cpu_temp_c"`
	UptimeSeconds int64   `json:"uptime_seconds"`
	DiskPercent   float64 `json:"disk_percent"`
}

SystemStats represents the live system metrics

func GetSystemStats

func GetSystemStats() SystemStats

GetSystemStats returns the latest cached system stats safely

Jump to

Keyboard shortcuts

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