price

package
v0.132.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataPerTokenAndCurrency

type DataPerTokenAndCurrency = map[string]map[string]DataPoint

type DataPoint

type DataPoint struct {
	Price     float64
	UpdatedAt int64
}

type Manager

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

func NewManager

func NewManager(priceProvider Provider) *Manager

func (*Manager) FetchPrice

func (pm *Manager) FetchPrice(symbol string, currency string) (float64, error)

func (*Manager) FetchPrices

func (pm *Manager) FetchPrices(symbols []string, currencies []string) (map[string]map[string]float64, error)

func (*Manager) GetCachedPrices

func (pm *Manager) GetCachedPrices() DataPerTokenAndCurrency

func (*Manager) GetOrFetchPrices

func (pm *Manager) GetOrFetchPrices(symbols []string, currencies []string, maxAgeInSeconds int64) (DataPerTokenAndCurrency, error)

Return cached price if present in cache and age is less than maxAgeInSeconds. Fetch otherwise.

type Provider

type Provider interface {
	FetchPrices(symbols []string, currencies []string) (map[string]map[string]float64, error)
}

Jump to

Keyboard shortcuts

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