events

package
v0.31.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish(e Event)

func PublishWithPayload added in v0.31.0

func PublishWithPayload(eventType EventType, payload any) error

func Subscribe

func Subscribe(buffer int) (string, <-chan Event, func())

Types

type CleanupTriggeredPayload added in v0.31.0

type CleanupTriggeredPayload struct {
	RemovedCount int64   `json:"removed_count"`
	FreedSpaceGB float64 `json:"freed_space_gb"`
}

type DiskLowPayload added in v0.31.0

type DiskLowPayload struct {
	FreeSpaceGB   float64 `json:"free_space_gb"`
	MinRequiredGB float64 `json:"min_required_gb"`
	Message       string  `json:"message"`
}

type Event

type Event struct {
	Type    EventType
	Version int64
	Source  string
	At      time.Time
	Payload json.RawMessage `json:"Payload,omitempty"`
}

type EventType

type EventType string
const (
	ConfigChanged EventType = "ConfigChanged"
	DiskSpaceLow  EventType = "DiskSpaceLow"
)
const EvtCleanupTriggered EventType = "cleanup.triggered"

EvtCleanupTriggered: Published when auto-cleanup (auto-delete) is triggered. Triggered by scheduler/cleanup_monitor.go after removing torrents.

const EvtDiskLow EventType = "disk.low"

EvtDiskLow: Published when disk space falls below minimum threshold (CleanupMinDiskSpaceGB). Triggered by internal/push.go disk protection check and scheduler/cleanup_monitor.go.

const EvtFreeEnded EventType = "free.ended"

EvtFreeEnded: Published when a free torrent's free period has ended. Triggered by scheduler/free_end_monitor.go at deadline; may trigger auto-pause or auto-delete.

const EvtFreeEndingSoon EventType = "free.ending_soon"

EvtFreeEndingSoon: Published when a free torrent's free period is ending soon (< 1 hour remaining). Triggered by scheduler/free_end_monitor.go before deadline.

const EvtNotificationDelivered EventType = "notification.delivered"

EvtNotificationDelivered: Published when a notification is successfully delivered via a channel. Triggered by internal/notify/outbox.go after successful send to Telegram/QQ/Webhook/etc.

const EvtNotificationFailed EventType = "notification.failed"

EvtNotificationFailed: Published when a notification fails to deliver. Triggered by internal/notify/outbox.go after exhausting retries or immediate send error.

const EvtSiteLoginExpired EventType = "site.login_expired"

EvtSiteLoginExpired: Published when a site login/cookie has expired or is invalid. Triggered by site drivers when authentication fails (HTTP 401/403 or login page redirect).

const EvtSiteScrapedDaily EventType = "site.scraped_daily"

EvtSiteScrapedDaily: Published as a daily summary event after scraping a site. Triggered by internal/common.go RSS fetch pipeline (if implemented) or site drivers.

const EvtTorrentAdded EventType = "torrent.added"

EvtTorrentAdded: Published when a torrent is successfully added to a downloader. Triggered by the RSS pipeline after pushing to a downloader via internal/push.go or manual download.

const EvtTorrentCompleted EventType = "torrent.completed"

EvtTorrentCompleted: Published when a torrent download completes (100% downloaded). Triggered by downloader status update monitors (future integration with downloader APIs).

const EvtTorrentFailed EventType = "torrent.failed"

EvtTorrentFailed: Published when a torrent fails to download (error state in downloader). Triggered by downloader status monitors and error handlers.

type FreeEndedPayload added in v0.31.0

type FreeEndedPayload struct {
	TorrentID string `json:"torrent_id"`
	SiteName  string `json:"site_name"`
	Title     string `json:"title"`
}

type FreeEndingSoonPayload added in v0.31.0

type FreeEndingSoonPayload struct {
	TorrentID  string `json:"torrent_id"`
	SiteName   string `json:"site_name"`
	FreeEndsAt int64  `json:"free_ends_at"` // Unix timestamp
}

type NotificationDeliveredPayload added in v0.31.0

type NotificationDeliveredPayload struct {
	NotifID   string `json:"notif_id"`
	Channel   string `json:"channel"` // "telegram", "qq", "webhook", "wecom", etc.
	Recipient string `json:"recipient"`
}

type NotificationFailedPayload added in v0.31.0

type NotificationFailedPayload struct {
	NotifID  string `json:"notif_id"`
	Channel  string `json:"channel"`
	ErrorMsg string `json:"error_msg"`
}

type SiteLoginExpiredPayload added in v0.31.0

type SiteLoginExpiredPayload struct {
	SiteName string `json:"site_name"`
	Message  string `json:"message"`
}

type SiteScrapedDailyPayload added in v0.31.0

type SiteScrapedDailyPayload struct {
	SiteName      string `json:"site_name"`
	TorrentsCount int64  `json:"torrents_count"`
}

type TorrentAddedPayload added in v0.31.0

type TorrentAddedPayload struct {
	TorrentID      string `json:"torrent_id"`
	SiteName       string `json:"site_name"`
	Title          string `json:"title"`
	Size           int64  `json:"size"`
	DownloaderName string `json:"downloader_name"`
}

type TorrentCompletedPayload added in v0.31.0

type TorrentCompletedPayload struct {
	TorrentID string `json:"torrent_id"`
	SiteName  string `json:"site_name"`
	Title     string `json:"title"`
}

type TorrentFailedPayload added in v0.31.0

type TorrentFailedPayload struct {
	TorrentID string `json:"torrent_id"`
	ErrorMsg  string `json:"error_msg"`
}

Jump to

Keyboard shortcuts

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