Documentation
¶
Index ¶
- func UpdateSubscription(sub *xsqlite.Subscription, db *gorm.DB, downloader downloader) (int, []string, error)
- type SubscriptionManager
- func (s *SubscriptionManager) Close() error
- func (s *SubscriptionManager) GetLastUpdate() time.Time
- func (s *SubscriptionManager) SetAutoUpdate(autoUpdate bool)
- func (s *SubscriptionManager) SetInterval(interval time.Duration)
- func (s *SubscriptionManager) Start() error
- func (s *SubscriptionManager) UpdateSubscriptions() error
- type SubscriptionOption
- type UpdateSubscriptionResult
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
Click to show internal directories.
Click to hide internal directories.