foreignscrapers

package
v1.0.1-tekton-ci-beta-12 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGenericForeignScraper

func NewGenericForeignScraper() *genericScraper

Types

type CoinMarketCapListing

type CoinMarketCapListing struct {
	Data []struct {
		ID                int              `json:"id"`
		Name              string           `json:"name"`
		Symbol            string           `json:"symbol"`
		Slug              string           `json:"slug"`
		CmcRank           int              `json:"cmc_rank"`
		NumMarketPairs    int              `json:"num_market_pairs"`
		CirculatingSupply float64          `json:"circulating_supply"`
		TotalSupply       float64          `json:"total_supply"`
		MaxSupply         float64          `json:"max_supply"`
		LastUpdated       string           `json:"last_updated"`
		DateAdded         string           `json:"date_added"`
		Tags              []string         `json:"tags"`
		Platform          interface{}      `json:"platform"`
		Quote             map[string]Quote `json:"quote"`
	} `json:"data"`
	Status struct {
		Timestamp    time.Time `json:"timestamp"`
		ErrorCode    int       `json:"error_code"`
		ErrorMessage string    `json:"error_message"`
		Elapsed      int       `json:"elapsed"`
		CreditCount  int       `json:"credit_count"`
	} `json:"status"`
}

type CoinMarketCapScraper

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

func NewCoinMarketCapScraper

func NewCoinMarketCapScraper(datastore models.Datastore) *CoinMarketCapScraper

func (*CoinMarketCapScraper) Close

func (scraper *CoinMarketCapScraper) Close() error

// closes all connected Scrapers. Must only be called from mainLoop func (scraper *CoinMarketCapScraper) cleanup(err error) {

	scraper.foreignScrapper.errorLock.Lock()
	defer scraper.foreignScrapper.errorLock.Unlock()

	scraper.foreignScrapper.tickerRate.Stop()
	scraper.foreignScrapper.tickerState.Stop()

	if err != nil {
		scraper.foreignScrapper.error = err
	}
	scraper.foreignScrapper.closed = true

	close(scraper.foreignScrapper.shutdownDone) // signal that shutdown is complete
}

Close closes any existing API connections

func (*CoinMarketCapScraper) GetQuoteChannel

func (scraper *CoinMarketCapScraper) GetQuoteChannel() chan *models.ForeignQuotation

func (*CoinMarketCapScraper) UpdateQuotation

func (scraper *CoinMarketCapScraper) UpdateQuotation() error

Update retrieves new coin information from the CoinMarketCap API and stores it to influx

type CoingeckoCoin

type CoingeckoCoin struct {
	ID                 string  `json:"id"`
	Symbol             string  `json:"symbol"`
	Name               string  `json:"name"`
	CurrentPrice       float64 `json:"current_price"`
	Yesterday24hVolume float64 `json:"total_volume"`
	LastUpdated        string  `json:"last_updated"`
}

type CoingeckoScraper

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

func NewCoingeckoScraper

func NewCoingeckoScraper(datastore models.Datastore) *CoingeckoScraper

func (*CoingeckoScraper) Close

func (scraper *CoingeckoScraper) Close() error

// closes all connected Scrapers. Must only be called from mainLoop func (scraper *CoingeckoScraper) cleanup(err error) {

	scraper.foreignScrapper.errorLock.Lock()
	defer scraper.foreignScrapper.errorLock.Unlock()

	scraper.foreignScrapper.tickerRate.Stop()
	scraper.foreignScrapper.tickerState.Stop()

	if err != nil {
		scraper.foreignScrapper.error = err
	}
	scraper.foreignScrapper.closed = true

	close(scraper.foreignScrapper.shutdownDone) // signal that shutdown is complete
}

Close closes any existing API connections

func (*CoingeckoScraper) GetQuoteChannel

func (scraper *CoingeckoScraper) GetQuoteChannel() chan *models.ForeignQuotation

func (*CoingeckoScraper) UpdateQuotation

func (scraper *CoingeckoScraper) UpdateQuotation() error

Update retrieves new coin information from the coingecko API and stores it to influx

type ForeignScraper

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

type ForeignScrapperer

type ForeignScrapperer interface {
	UpdateQuotation() error
	GetQuoteChannel() chan *models.ForeignQuotation
}

type Quote

type Quote struct {
	Price            float64 `json:"price"`
	Volume24H        float64 `json:"volume_24h"`
	PercentChange1H  float64 `json:"percent_change_1h"`
	PercentChange24H float64 `json:"percent_change_24h"`
	PercentChange7D  float64 `json:"percent_change_7d"`
	MarketCap        float64 `json:"market_cap"`
	LastUpdated      string  `json:"last_updated"`
}

Jump to

Keyboard shortcuts

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