pricefeeder

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(store PriceFeedStore) ports.PriceFeeder

Types

type Market

type Market struct {
	BaseAsset  string
	QuoteAsset string
}

func (Market) GetBaseAsset

func (m Market) GetBaseAsset() string

func (Market) GetQuoteAsset

func (m Market) GetQuoteAsset() string

type PriceFeedInfo

type PriceFeedInfo struct {
	ID      string
	Market  Market
	Source  string
	Ticker  string
	Started bool
}

func NewPriceFeedInfo

func NewPriceFeedInfo(market ports.Market, source, ticker string) (*PriceFeedInfo, error)

func (PriceFeedInfo) GetId

func (p PriceFeedInfo) GetId() string

func (PriceFeedInfo) GetMarket

func (p PriceFeedInfo) GetMarket() ports.Market

func (PriceFeedInfo) GetSource

func (p PriceFeedInfo) GetSource() string

func (PriceFeedInfo) GetTicker

func (p PriceFeedInfo) GetTicker() string

func (PriceFeedInfo) IsStarted

func (p PriceFeedInfo) IsStarted() bool

type PriceFeedStore

type PriceFeedStore interface {
	// AddPriceFeed adds a new price feed to the repository.
	AddPriceFeed(ctx context.Context, info PriceFeedInfo) error
	// GetPriceFeed returns the price feed with the given ID.
	GetPriceFeed(ctx context.Context, id string) (*PriceFeedInfo, error)
	// UpdatePriceFeed updates the price feed.
	UpdatePriceFeed(
		ctx context.Context, id string,
		updateFn func(priceFeed *PriceFeedInfo) (*PriceFeedInfo, error),
	) error
	// RemovePriceFeed removes the price feed with the given ID.
	RemovePriceFeed(ctx context.Context, id string) error
	// GetAllPriceFeeds returns all price feeds of all markets.
	GetAllPriceFeeds(ctx context.Context) ([]PriceFeedInfo, error)
	Close()
}

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

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