subscription

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateSubscription

func UpdateSubscription(sub *xsqlite.Subscription, db *gorm.DB, downloader downloader) (int, []string, error)

return success parsed nodes, failed parsed nodes, error error means cannot get data from server

Types

type SubscriptionManager

type SubscriptionManager struct {
	Running           bool
	Timer             *time.Timer
	Interval          time.Duration
	Downloader        downloader
	Db                *gorm.DB
	OnUpdatedCallback func()
	AutoUpdate        bool
}

func NewSubscriptionManager

func NewSubscriptionManager(interval time.Duration, db *gorm.DB, downloader downloader,
	opts ...SubscriptionOption) *SubscriptionManager

func (*SubscriptionManager) Close

func (s *SubscriptionManager) Close() error

func (*SubscriptionManager) GetLastUpdate

func (s *SubscriptionManager) GetLastUpdate() time.Time

func (*SubscriptionManager) SetAutoUpdate

func (s *SubscriptionManager) SetAutoUpdate(autoUpdate bool)

func (*SubscriptionManager) SetInterval

func (s *SubscriptionManager) SetInterval(interval time.Duration)

just set interval, not start or stop

func (*SubscriptionManager) Start

func (s *SubscriptionManager) Start() error

func (*SubscriptionManager) UpdateSubscriptions

func (s *SubscriptionManager) UpdateSubscriptions() error

type SubscriptionOption

type SubscriptionOption func(*SubscriptionManager)

func WithDownloader

func WithDownloader(downloader downloader) SubscriptionOption

func WithOnUpdatedCallback

func WithOnUpdatedCallback(callback func()) SubscriptionOption

func WithPeriodicUpdate

func WithPeriodicUpdate(periodicUpdate bool) SubscriptionOption

type UpdateSubscriptionResult

type UpdateSubscriptionResult struct {
	SuccessSub   int
	SuccessNodes int
	FailedSub    int
	FailedNodes  []string
	ErrorReasons map[string]string
}

func UpdateSubscriptions

func UpdateSubscriptions(db *gorm.DB, downloader downloader) UpdateSubscriptionResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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