feeder

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "FEEDER"

Variables

This section is empty.

Functions

This section is empty.

Types

type Feedable

type Feedable interface {
	// OriginPair returns the origin and pair which are acceptable for
	// this Node.
	OriginPair() nodes.OriginPair
	// Ingest sets the Price for this Node. It may return error if
	// the OriginPrice contains incompatible origin or pair.
	Ingest(price nodes.OriginPrice) error
	// MinTTL is the amount of time during which the Price shouldn't be updated.
	MinTTL() time.Duration
	// MaxTTL is the maximum amount of time during which the Price can be used.
	// After that time, the Price method will return a OriginPrice with
	// a ErrPriceTTLExpired error.
	MaxTTL() time.Duration
	// Expired returns true if the Price is expired. This is based on the MaxTTL
	// value.
	Expired() bool
	// Price returns the Price assigned in the Ingest method. If the Price is
	// expired then a ErrPriceTTLExpired error will be set in
	// the OriginPrice.Error field.
	Price() nodes.OriginPrice
}

type Feeder

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

Feeder sets prices from origins to the Feedable nodes.

func NewFeeder

func NewFeeder(ctx context.Context, set *origins.Set, log log.Logger) *Feeder

NewFeeder creates new Feeder instance.

func (*Feeder) Feed

func (f *Feeder) Feed(ns ...nodes.Node) Warnings

Feed sets Prices to Feedable nodes. This method takes list of root nodes and sets Prices to all of their children that implement the Feedable interface.

func (*Feeder) Start

func (f *Feeder) Start(ns ...nodes.Node) error

Start starts a goroutine which updates prices as often as the lowest TTL is.

func (*Feeder) Wait

func (f *Feeder) Wait() chan error

Wait waits until feeder's context is cancelled.

type Warnings

type Warnings struct {
	List []error
}

Warnings contains a list of minor errors which occurred during fetching prices.

func (Warnings) ToError

func (w Warnings) ToError() error

Jump to

Keyboard shortcuts

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