store

package
v0.0.0-...-7206d32 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("no data found")
)

Functions

func Load

func Load(ctx context.Context, path string, s *Storer) error

Types

type SQLiteStorage

type SQLiteStorage struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

func NewSQLite

func NewSQLite(ctx context.Context, path string) (*SQLiteStorage, error)

func (*SQLiteStorage) Log

func (s *SQLiteStorage) Log(reqType, request string) error

func (*SQLiteStorage) Read

func (s *SQLiteStorage) Read(date time.Time) (res data.Rates, err error)

Read reads rates from the database

func (*SQLiteStorage) ReadLogs

func (s *SQLiteStorage) ReadLogs() (logs []string, err error)

func (*SQLiteStorage) Write

func (s *SQLiteStorage) Write(d data.Rates) error

type Storer

type Storer interface {
	// Read reads records for the given module from the database
	Read(time.Time) (data.Rates, error)
	// Write writes the data to the database
	Write(data.Rates) error
	// Log requests to the database
	Log(string, string) error
	// ReadLogs return 10 most recent logs from the database
	ReadLogs() ([]string, error)
}

Jump to

Keyboard shortcuts

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