index

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentName = "trackerIndex"

	MetricIndexValue = ComponentName + "_value"
	MetricInterval   = ComponentName + "_interval"
	MetricRecCount   = ComponentName + "_requests_total"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Apis

type Apis struct {
	// The recommended interval for calling the Get method.
	// Some APIs will return an error if called more often
	// Due to API rate limiting of the provider.
	Interval  format.Duration
	Endpoints []Endpoint
}

Apis will be used in parsing index file.

type Balancer

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

Balancer implements DataSource interface.

func NewBalancer

func NewBalancer(pair, address string, interval time.Duration, client bind.ContractCaller) *Balancer

func (*Balancer) Get

func (b *Balancer) Get(ctx context.Context) (float64, float64, error)

func (*Balancer) Interval

func (b *Balancer) Interval() time.Duration

func (*Balancer) Source

func (b *Balancer) Source() string

type BalancerPair

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

BalancerPair to be fetched onchain.

type Bravenewcoin

type Bravenewcoin struct {
	*JSONapi
	// contains filtered or unexported fields
}

func NewBravenewcoin

func NewBravenewcoin(interval time.Duration, urlString string, parser Parser) (*Bravenewcoin, error)

func (*Bravenewcoin) Get

func (self *Bravenewcoin) Get(ctx context.Context) (float64, float64, error)

type Config

type Config struct {
	LogLevel  string
	Interval  format.Duration
	IndexFile string
}

type DataSource

type DataSource interface {
	// Source returns the data source.
	Source() string
	// Get returns current api value.
	Get(context.Context) (float64, float64, error)
	// The recommended interval for calling the Get method.
	// Some APIs will return an error if called more often
	// Due to API rate limiting of the provider.
	Interval() time.Duration
}

type Endpoint

type Endpoint struct {
	URL        string
	Type       IndexType
	Parser     ParserType
	Value      string
	Time       string
	TimeFormat string
}

type IndexType

type IndexType string

IndexType -> index type for Api.

type JSONapi

type JSONapi struct {
	Parser
	URLExpander
	// contains filtered or unexported fields
}

func NewJSONapi

func NewJSONapi(interval time.Duration, url string, parser Parser) *JSONapi

func (*JSONapi) Get

func (self *JSONapi) Get(ctx context.Context) (float64, float64, error)

func (*JSONapi) Interval

func (self *JSONapi) Interval() time.Duration

func (*JSONapi) Source

func (self *JSONapi) Source() string

type JSONapiVolume

type JSONapiVolume struct {
	*JSONapi
	// contains filtered or unexported fields
}

func NewJSONapiVolume

func NewJSONapiVolume(interval time.Duration, url string, parser Parser) *JSONapiVolume

NewJSONapiVolume are treated differently and return 0 values when the api returns the same timestamp. This is to avoid double counting volumes for the same time period. Another way is to skip adding the data, but this messes up the confidence calculations which counts total added data points.

func (*JSONapiVolume) Get

func (self *JSONapiVolume) Get(ctx context.Context) (float64, float64, error)

type JqParser

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

func (*JqParser) Parse

func (self *JqParser) Parse(input []byte, paramName string) (float64, error)

type JsonPathParser

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

func (*JsonPathParser) Parse

func (self *JsonPathParser) Parse(input []byte, paramName string) (float64, error)

type Parser

type Parser interface {
	Parse(data []byte, paramName string) (value float64, err error)
}

func NewParser

func NewParser(t Endpoint) Parser

type ParserType

type ParserType string

ParserType -> index parser for Api.

type TrackerIndex

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

func New

func New(
	ctx context.Context,
	logger log.Logger,
	cfg Config,
	db *tsdb.DB,
) (*TrackerIndex, error)

func (*TrackerIndex) Start

func (self *TrackerIndex) Start() error

func (*TrackerIndex) Stop

func (self *TrackerIndex) Stop()

type URLEnvExpander

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

func (*URLEnvExpander) UrlExpanded

func (self *URLEnvExpander) UrlExpanded() (string, error)

func (*URLEnvExpander) UrlRaw

func (self *URLEnvExpander) UrlRaw() string

type URLExpander

type URLExpander interface {
	UrlExpanded() (string, error)
	UrlRaw() string
}

type Uniswap

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

Uniswap implements DataSource interface.

func NewUniswap

func NewUniswap(pair string, address string, interval time.Duration, client bind.ContractCaller) *Uniswap

NewUniswap creates new Uniswap for provided pair and pair address.

func (*Uniswap) Get

func (self *Uniswap) Get(ctx context.Context) (float64, float64, error)

Get calculates price for the provided pair.

func (*Uniswap) Interval

func (self *Uniswap) Interval() time.Duration

func (*Uniswap) Source

func (self *Uniswap) Source() string

Jump to

Keyboard shortcuts

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