controller

package
v0.0.0-...-74b37bb Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportCompanies

func ImportCompanies(filePath string, r Redis) error

func SetRedis

func SetRedis(redis Redis)

Types

type Company

type Company struct {
	Symbol    string  `json:"symbol"`
	Company   string  `json:"company"`
	Country   string  `json:"country"`
	MarketCap float64 `json:"marketCap"`
	Rank      int     `json:"rank"`
}

func (*Company) GetKey

func (c *Company) GetKey() string

type Controller

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

func Instance

func Instance() *Controller

func (Controller) All

func (c Controller) All() ([]*Company, error)

func (Controller) Bottom10

func (c Controller) Bottom10() ([]*Company, error)

func (Controller) GetBySymbol

func (c Controller) GetBySymbol(symbols []string) ([]*Company, error)

func (Controller) InRank

func (c Controller) InRank(start, end int64) ([]*Company, error)

func (Controller) Top10

func (c Controller) Top10() ([]*Company, error)

func (Controller) UpdateRank

func (c Controller) UpdateRank(symbol string, amount float64) error

type Redis

type Redis interface {
	HSet(key, field string, value interface{}) error
	HGetAll(key string) (map[string]string, error)
	ZAdd(key string, member string, score float64) error
	ZRevRange(key string, start, stop int64) ([]*Company, error)
	ZRange(key string, start, stop int64) ([]*Company, error)
	ZScore(key, member string) (float64, error)
	ZIncrBy(key string, increment float64, member string) error
	ZCount(key, min, max string) (int64, error)
}

Jump to

Keyboard shortcuts

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