fetchers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaemonFetcher

type DaemonFetcher interface {
	Start(context.Context)
	// Stop the fetcher
	// TODO using ch to stop
	Stop()
	// Notify is used to notify fetcher to fetch data now.
	// isHardRefresh is used to indicate whether to clean cache.
	// return a chan to notify whether fetch success.
	Notify(isHardRefresh bool) (chan bool, error)
	Fetch(isHardRefresh bool) error
	// UIRefresh is used to notify ui app to refresh
	UIRefresh() chan bool
}

DaemonFetcher is a interface for one fetcher it runs in background and fetch data from remote.

func NewSimpleFetcher

func NewSimpleFetcher(
	log logrus.FieldLogger,
	interval time.Duration,
	fn FetchFn,
	statusDescriber StatusDescriber,
) DaemonFetcher

type FetchFn

type FetchFn func(sd StatusDescriber, isHardRefresh bool) error

FetchFn fetch data.

type FetchPromise

type FetchPromise struct {
	Done          chan bool
	IsHardRefresh bool
}

type Progress

type Progress func() int

type StatusDescriber

type StatusDescriber interface {
	Progress() (int, int)
	SetProgress(current int, total int)

	OnSyncing(func() error)
	OnSuccess(func() error)
	OnError(func(err error) error)

	Error(err error)
	Success()
	Syncing()
}

StatusDescriber is a interface for describe the status of fetcher it gets progress from syncer, and invoke registered callback.

func NewNoOpStatusDescriber

func NewNoOpStatusDescriber() StatusDescriber

func NewStatusDescriber

func NewStatusDescriber(onSyncing, onSuccess func() error, onError func(err error) error) StatusDescriber

type ToodledoFetchFunc

type ToodledoFetchFunc struct {
	// contains filtered or unexported fields
}

func (*ToodledoFetchFunc) Fetch

func (s *ToodledoFetchFunc) Fetch(statusDescriber StatusDescriber, isHardRefresh bool) error

Jump to

Keyboard shortcuts

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