repo

package
v0.0.0-...-12e33ea Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BetDetail

type BetDetail struct {
	User      string
	Number    int
	ExtraInfo string
}

type BetSummary

type BetSummary struct {
	ID           int
	Status       string
	StartDate    string
	EndDate      string
	WinnerNumber int
}

func (*BetSummary) String

func (b *BetSummary) String() string

type RedisRepo

type RedisRepo struct {
	Url string
}

func (*RedisRepo) AddNewBet

func (repo *RedisRepo) AddNewBet(betID int, startDate string) error

AddNewBet adds a new bet info with given id and startDate. returns error in case of a connection error.

func (*RedisRepo) BetIDExists

func (repo *RedisRepo) BetIDExists(betID int) (bool, error)

BetIDExists returns true if a bet with given id exists returns error for any connection error

func (*RedisRepo) GetBetDetails

func (repo *RedisRepo) GetBetDetails(betID int) ([]BetDetail, error)

GetBetDetails finds and returns details list of the bet. returns error in case of a connection error.

func (*RedisRepo) GetBetSummary

func (repo *RedisRepo) GetBetSummary(betID int) (*BetSummary, error)

GetBetSummary returns summary of bet with ID return error for any connection error

func (*RedisRepo) GetIDOfOpenBet

func (repo *RedisRepo) GetIDOfOpenBet() (int, error)

GetIDOfOpenBet returns the id of the open bet if there is any. in redis, openBet is indicated by `OpenBet` identifier. returns error in case of a connection error.

func (*RedisRepo) GetLastBetID

func (repo *RedisRepo) GetLastBetID() (int, error)

GetLastBetID returns the last inserted bet id into the system returns error in case of a connection error.

func (*RedisRepo) GetWinnerScore

func (repo *RedisRepo) GetWinnerScore(betID int) (int, error)

GetWinnerScore returns the winner score that belongs to the bet with betID. Returns -1 if bet doesn't have a winnerScore. returns error in case of a connection error.

func (*RedisRepo) SetBetAsEnded

func (repo *RedisRepo) SetBetAsEnded(betID int, date string) error

SetBetAsEnded marks the bet as ended and sets the endDate with given date. returns error in case of a connection error.

func (*RedisRepo) SetBetDetail

func (repo *RedisRepo) SetBetDetail(betID int, details []BetDetail) error

func (*RedisRepo) SetBetWinner

func (repo *RedisRepo) SetBetWinner(betID int, winner int) error

SetBetWinner sets the winner field of the bet. returns error in case of a connection error.

type Repo

type Repo interface {
	AddNewBet(int, string) error
	BetIDExists(betID int) (bool, error)
	GetBetDetails(int) ([]BetDetail, error)
	GetIDOfOpenBet() (int, error)
	GetLastBetID() (int, error)
	GetWinnerScore(int) (int, error)
	SetBetAsEnded(int, string) error
	SetBetDetail(int, []BetDetail) error
	SetBetWinner(int, int) error
	GetBetSummary(betID int) (*BetSummary, error)
}

Jump to

Keyboard shortcuts

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