notional

package
v0.0.0-...-19b0ade Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

View Source
const (
	KeyTokenFormatString = "WORMSCAN:NOTIONAL:TOKEN:%s"
)

Variables

View Source
var (
	ErrNotFound          = errors.New("NOT FOUND")
	ErrInvalidCacheField = errors.New("INVALID CACHE FIELD")
)

Functions

This section is empty.

Types

type DummyNotionalCache

type DummyNotionalCache struct {
}

DummyNotionalCache is a dummy notional cache.

func NewDummyNotionalCache

func NewDummyNotionalCache() *DummyNotionalCache

NewDummyNotionalCache init a new dummy notional cache.

func (*DummyNotionalCache) Close

func (c *DummyNotionalCache) Close() error

Close the dummy cache.

func (*DummyNotionalCache) Get

func (c *DummyNotionalCache) Get(symbol domain.Symbol) (PriceData, error)

Get get notional cache value.

type NotionalCache

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

NotionalCacheClient redis cache client.

func NewNotionalCache

func NewNotionalCache(ctx context.Context, redisClient *redis.Client, prefix string, channel string, log *zap.Logger) (*NotionalCache, error)

NewNotionalCache create a new cache client. After create a NotionalCache use the Init method to initialize pubsub and load the cache.

func (*NotionalCache) Close

func (c *NotionalCache) Close() error

Close the pubsub channel.

func (*NotionalCache) Get

func (c *NotionalCache) Get(tokenID string) (PriceData, error)

Get notional cache value.

func (*NotionalCache) Init

func (c *NotionalCache) Init(ctx context.Context) error

Init subscribe to notional pubsub and load the cache.

type NotionalLocalCacheReadable

type NotionalLocalCacheReadable interface {
	Get(tokenID string) (PriceData, error)
	Close() error
}

NotionalLocalCacheReadable is the interface for notional local cache.

type PriceData

type PriceData struct {
	NotionalUsd decimal.Decimal `json:"notional_usd"`
	UpdatedAt   time.Time       `json:"updated_at"`
}

PriceData is the notional value of assets in cache.

func (PriceData) MarshalBinary

func (p PriceData) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

This function is used when the notional job writes data to redis.

Jump to

Keyboard shortcuts

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