graph

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "ASYNC_GOFER"

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncGofer

type AsyncGofer struct {
	*Gofer
	// contains filtered or unexported fields
}

AsyncGofer implements the gofer.Gofer interface. It works just like Gofer but allows updating prices asynchronously.

func NewAsyncGofer

func NewAsyncGofer(
	graph map[gofer.Pair]nodes.Aggregator,
	feeder *feeder.Feeder,
	nodes []nodes.Node,
	logger log.Logger,
) (*AsyncGofer, error)

NewAsyncGofer returns a new AsyncGofer instance.

func (*AsyncGofer) Start

func (a *AsyncGofer) Start(ctx context.Context) error

Start starts asynchronous price updater.

func (*AsyncGofer) Wait

func (a *AsyncGofer) Wait() chan error

Wait waits until the context is canceled or until an error occurs.

type ErrPairNotFound

type ErrPairNotFound struct {
	Pair gofer.Pair
}

func (ErrPairNotFound) Error

func (e ErrPairNotFound) Error() string

type Gofer

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

Gofer implements the gofer.Gofer interface. It uses a graph structure to calculate pairs prices.

func NewGofer

func NewGofer(graph map[gofer.Pair]nodes.Aggregator, feeder *feeder.Feeder) *Gofer

NewGofer returns a new Gofer instance. If the Feeder is not nil, then prices are automatically updated when the Price or Prices methods are called. Otherwise, prices have to be updated externally.

func (*Gofer) Models

func (g *Gofer) Models(pairs ...gofer.Pair) (map[gofer.Pair]*gofer.Model, error)

Models implements the gofer.Gofer interface.

func (*Gofer) Pairs

func (g *Gofer) Pairs() ([]gofer.Pair, error)

Pairs implements the gofer.Gofer interface.

func (*Gofer) Price

func (g *Gofer) Price(pair gofer.Pair) (*gofer.Price, error)

Price implements the gofer.Gofer interface.

func (*Gofer) Prices

func (g *Gofer) Prices(pairs ...gofer.Pair) (map[gofer.Pair]*gofer.Price, error)

Prices implements the gofer.Gofer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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