github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/foreign-scrapers/Scrapper.go (about) 1 package foreignscrapers 2 3 import ( 4 "sync" 5 6 models "github.com/diadata-org/diadata/pkg/model" 7 log "github.com/sirupsen/logrus" 8 ) 9 10 type ForeignScrapperer interface { 11 UpdateQuotation() error 12 GetQuoteChannel() chan *models.ForeignQuotation 13 } 14 15 type ForeignScraper struct { 16 // signaling channels 17 shutdown chan nothing 18 shutdownDone chan nothing 19 20 // error handling; to read error or closed, first acquire read lock 21 // only cleanup method should hold write lock 22 errorLock *sync.RWMutex 23 error error 24 closed bool 25 // TODO: check after linting 26 // tickerRate *time.Ticker 27 // tickerState *time.Ticker 28 datastore models.Datastore 29 chanQuotation chan *models.ForeignQuotation 30 } 31 32 // The below generic scraper is an empty scraper used for the default case of the main function 33 type genericScraper struct{} 34 35 func (scraper *genericScraper) UpdateQuotation() error { 36 return nil 37 } 38 func (scraper *genericScraper) GetQuoteChannel() chan *models.ForeignQuotation { 39 return make(chan *models.ForeignQuotation) 40 } 41 func NewGenericForeignScraper() *genericScraper { 42 s := &genericScraper{} 43 log.Info("started genericforeignscraper") 44 return s 45 }