Documentation
¶
Index ¶
- Constants
- Variables
- func AddSession(userID int64) (string, error)
- func AddTeam(owner int64, teamName string, region string, position int, top int64, ...) error
- func CacheSummoner(region string, normalizedName string, summoner rgapi.Summoner) (int64, error)
- func Connect() error
- func DeleteSession(sessionID string) error
- func DeleteTeam(teamID int64) error
- func GetRandomTeams(numTeams int) (*[]FantasyTeam, error)
- func GetTeams(userID int64) (*[]FantasyTeam, error)
- func GetUserIDFromSession(sessionID string) (int64, error)
- func GetUsername(userID int64) (string, error)
- func Login(username string, password string) (string, error)
- func PreparePepper() error
- func Register(username string, password string) (string, error)
- func UncacheSummonerByAccountId(region string, accountId int64) (rgapi.Summoner, int64, error)
- func UncacheSummonerByCacheID(summonerCacheID int64) (rgapi.Summoner, error)
- func UncacheSummonerByName(region string, normalizedName string) (rgapi.Summoner, int64, error)
- func UpdateTeam(teamID int64, owner int64, teamName string, region string, position int, ...) error
- type FantasyTeam
Constants ¶
const ( QueryGetSummonerByName = "getSummonerByName" QueryGetSummonerByAccountId = "getSummonerByAccountId" QueryGetSummonerByCacheID = "getSummonerByCacheID" QueryUpsertSummoner = "upsertSummoner" )
Queries that are prepared for easy calling
const ( QueryGetTeams = "getTeams" QueryGetRandomTeams = "getRandomTeams" QueryInsertTeam = "insertTeam" QueryUpdateTeam = "updateTeam" QueryDeleteTeam = "deleteTeam" )
Queries that are prepared for easy calling
const ( QueryGetUserAccountByUsername = "getUserAccount" QueryPutUserAccount = "putUserAccount" QueryGetUsername = "getUsername" )
Queries that are prepared for easy calling
const ( QueryGetSessionUserID = "getSession" QueryPutSession = "putSession" QueryDeleteSession = "deleteSession" )
Queries that are prepared for easy calling
const BcryptCost = 13
BcryptCost increases the number of rounds and time taken by the hash algorithm; safe to change this since the number of rounds is stored in the bcrypt hash, so will only apply to new passwords
const DBTimeout = 30 * time.Second
DBTimeout in seconds
const InsertionAttempts = 5
InsertionAttempts to generate a session ID. Honestly we should never even have a conflict
const MaxDBConnections = 5
MaxDBConnections the db can support
const SessionIDLength = 64
Variables ¶
var DBConnectionPool *pgx.ConnPool
DBConnectionPool is required for making queries to the DB
Functions ¶
func AddTeam ¶
func AddTeam(owner int64, teamName string, region string, position int, top int64, jungle int64, mid int64, bottom int64, support int64) error
AddTeam to database, errors if team already exists in that slot
func CacheSummoner ¶
CacheSummoner attempts to cache a summoner if it hasn't been cached before
func DeleteTeam ¶
DeleteTeam that already exists in the database
func GetRandomTeams ¶
func GetRandomTeams(numTeams int) (*[]FantasyTeam, error)
GetRandomTeams tries to retrieve numTeams non-bench fantasy teams from the DB
func GetTeams ¶
func GetTeams(userID int64) (*[]FantasyTeam, error)
GetTeams for the given user id from the database if they exist
func GetUserIDFromSession ¶
GetUserIDFromSession database table
func PreparePepper ¶
func PreparePepper() error
PreparePepper gets the pepper value from environment variables
func UncacheSummonerByAccountId ¶
UncacheSummonerByAccountId from database if it exists, return an error otherwise TODO: Do this in bulk, and perform the Riot API queries/caching here
func UncacheSummonerByCacheID ¶
UncacheSummonerByCacheID from database if it exists, return an error otherwise
func UncacheSummonerByName ¶
UncacheSummonerByName from database if it exists, return an error otherwise TODO: Do this in bulk, and perform the Riot API queries/caching here