handler

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRequestUrl

func CreateRequestUrl(baseUrl string, tickers []string) string

Types

type ExchangeQueryHandler

type ExchangeQueryHandler interface {
	lib.TimeProvider
	Query(
		ctx context.Context,
		exchangeQueryDetails *types.ExchangeQueryDetails,
		exchangeConfig *types.MutableExchangeMarketConfig,
		marketIds []types.MarketId,
		requestHandler lib.RequestHandler,
		marketPriceExponent map[types.MarketId]types.Exponent,
	) (marketPriceTimestamps []*types.MarketPriceTimestamp, unavailableMarkets map[types.MarketId]error, err error)
}

ExchangeQueryHandler is an interface that encapsulates querying an exchange for price info.

type ExchangeQueryHandlerImpl

type ExchangeQueryHandlerImpl struct {
	lib.TimeProvider
}

ExchangeQueryHandlerImpl is the struct that implements the `ExchangeQueryHandler` interface.

func (*ExchangeQueryHandlerImpl) Query

func (eqh *ExchangeQueryHandlerImpl) Query(
	ctx context.Context,
	exchangeQueryDetails *types.ExchangeQueryDetails,
	exchangeConfig *types.MutableExchangeMarketConfig,
	marketIds []types.MarketId,
	requestHandler lib.RequestHandler,
	marketPriceExponent map[types.MarketId]types.Exponent,
) (marketPriceTimestamps []*types.MarketPriceTimestamp, unavailableMarkets map[types.MarketId]error, err error)

Query makes an API call to a specific exchange and returns the transformed response, including both valid prices and any unavailable markets with specific errors. 1) Validate `marketIds` contains at least one id. 2) Convert the list of `marketIds` to tickers that are specific for a given exchange. Create a mapping of tickers to price exponents and a reverse mapping of ticker back to `MarketId`. 3) Make API call to an exchange and verify the response status code is not an error status code. 4) Transform the API response to market prices, while tracking unavailable tickers. 5) Return dual values: - a slice of `MarketPriceTimestamp`s that contains resolved market prices - a map of marketIds that could not be resolved with corresponding specific errors.

Jump to

Keyboard shortcuts

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