static

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Name is the name of the provider.
	Name = "static-mock-provider"
)

Variables

This section is empty.

Functions

func NewAPIHandler

func NewAPIHandler() types.PriceAPIDataHandler

NewAPIHandler returns a new MockAPIHandler. This constructs a new static mock provider from the config. Notice this method expects the market configuration map to the offchain ticker to the desired price.

Types

type MetaData

type MetaData struct {
	Price float64 `json:"price"`
}

MetaData is the per-ticker specific metadata that is used to configure the static provider.

func (*MetaData) FromJSON

func (m *MetaData) FromJSON(jsonStr string) error

FromJSON unmarshals the JSON data into a MetaData struct.

func (*MetaData) MustToJSON

func (m *MetaData) MustToJSON() string

MustToJSON marshals the MetaData struct into a JSON string.

type MockAPIHandler

type MockAPIHandler struct{}

MockAPIHandler implements a mock API handler that returns static data.

func (*MockAPIHandler) CreateURL

func (s *MockAPIHandler) CreateURL(_ []types.ProviderTicker) (string, error)

CreateURL is a no-op.

func (*MockAPIHandler) ParseResponse

func (s *MockAPIHandler) ParseResponse(
	tickers []types.ProviderTicker,
	_ *http.Response,
) types.PriceResponse

ParseResponse is a no-op. This simply returns the price of the tickers configured, timestamped with the current time.

type MockClient

type MockClient struct{}

MockClient is meant to be paired with the MockAPIHandler. It should only be used for testing.

func NewStaticMockClient

func NewStaticMockClient() *MockClient

func (*MockClient) Do

Do is a no-op.

func (*MockClient) Type

func (s *MockClient) Type() string

Type returns the HTTP method used to send requests.

Jump to

Keyboard shortcuts

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