Documentation
¶
Index ¶
- Constants
- func StoredDataPointLogFields(o StoredDataPoint) log.Fields
- type Config
- type DataPointProvider
- type MemoryStorage
- func (m *MemoryStorage) Add(_ context.Context, point StoredDataPoint) error
- func (m *MemoryStorage) Latest(_ context.Context, model string) (map[types.Address]StoredDataPoint, error)
- func (m *MemoryStorage) LatestFrom(_ context.Context, from types.Address, model string) (StoredDataPoint, bool, error)
- type Storage
- type Store
- type StoredDataPoint
Constants ¶
View Source
const LoggerTag = "DATA_POINT_STORE"
Variables ¶
This section is empty.
Functions ¶
func StoredDataPointLogFields ¶ added in v0.13.5
func StoredDataPointLogFields(o StoredDataPoint) log.Fields
Types ¶
type Config ¶
type Config struct {
// Storage is the storage implementation.
Storage Storage
// Transport is an implementation of transport used to fetch prices from feeds.
Transport transport.Service
// Models is the list of models which are supported by the store.
Models []string
// Recoverers is the list of recoverers which are used to recover the
// feed's address from the data point.
Recoverers []datapoint.Recoverer
// Logger is a current logger interface used by the Store.
// The Logger is required to monitor asynchronous processes.
Logger log.Logger
}
Config is the configuration for Storage.
type DataPointProvider ¶ added in v0.22.1
type DataPointProvider interface {
// LatestFrom returns the latest data point from a given address.
LatestFrom(ctx context.Context, from types.Address, model string) (StoredDataPoint, bool, error)
// Latest returns the latest data points from all addresses.
Latest(ctx context.Context, model string) (map[types.Address]StoredDataPoint, error)
}
DataPointProvider is an interface which provides latest data points from feeds.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage is an in-memory implementation of Storage.
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new MemoryStorage.
func (*MemoryStorage) Add ¶
func (m *MemoryStorage) Add(_ context.Context, point StoredDataPoint) error
Add implements the Storage interface.
func (*MemoryStorage) Latest ¶
func (m *MemoryStorage) Latest(_ context.Context, model string) (map[types.Address]StoredDataPoint, error)
Latest implements the Storage interface.
func (*MemoryStorage) LatestFrom ¶
func (m *MemoryStorage) LatestFrom(_ context.Context, from types.Address, model string) (StoredDataPoint, bool, error)
LatestFrom implements the Storage interface.
type Storage ¶
type Storage interface {
// Add adds a data point to the store.
//
// Adding a data point with a timestamp older than the latest data point
// for the same address and model will be ignored.
Add(ctx context.Context, point StoredDataPoint) error
// LatestFrom returns the latest data point from a given address.
LatestFrom(ctx context.Context, from types.Address, model string) (point StoredDataPoint, ok bool, err error)
// Latest returns the latest data points from all addresses.
Latest(ctx context.Context, model string) (points map[types.Address]StoredDataPoint, err error)
}
Storage is underlying storage implementation for the Store.
It must be thread-safe.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores latest data points from feeds.
func (*Store) Latest ¶
func (p *Store) Latest(ctx context.Context, model string) (map[types.Address]StoredDataPoint, error)
Latest implements the DataPointProvider interface.
func (*Store) LatestFrom ¶
func (p *Store) LatestFrom(ctx context.Context, from types.Address, model string) (StoredDataPoint, bool, error)
LatestFrom implements the DataPointProvider interface.
Click to show internal directories.
Click to hide internal directories.