Documentation ¶
Overview ¶
Package database provides an interface through which the application can interact with a database.
Package database provides an interface through which the application can interact with a database.
Package database provides an interface through which the application can interact with a database.
Index ¶
- func CreateMatch(client1DatabaseID uint64, client2DatabaseID uint64) (matchID uint64, err error)
- func GetClientNameAndAvatar(databaseID uint64) (displayname string, avatar uint8, err error)
- func GetMMR(databaseID uint64) (MMR int, err error)
- func Init()
- func SetMatchResult(matchID uint64, winnerDatabaseID uint64) (err error)
- func SetMatchStart(matchID uint64) (err error)
- func ValidateAuth(publicID string, authToken string) (databaseID uint64, err error)
- func ValidateMatch(databaseID uint64, matchID uint64) (valid bool, err error)
- type EnvironmentVariables
- type PreparedStatements
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMatch ¶
CreateMatch creates a match with the two clients specified, and returns the match id.
func GetClientNameAndAvatar ¶
GetClientNameAndAvatar returns the displayname and avatar id for the specified user.
func Init ¶
func Init()
Init should be called at the start of the function. It opens a connection to the database based on the parameters defined by environment variables, as specified by the EnvironmentVariables struct.
func SetMatchResult ¶
SetMatchResult updates the specified match with the winner, end time, and sets phase to 2 (finished).
func SetMatchStart ¶
SetMatchStart updates the phase + start time column for the specified match.
func ValidateAuth ¶
ValidateAuth checks the specified database ID and token to see if they match and are valid.
Types ¶
type EnvironmentVariables ¶
type EnvironmentVariables struct { DBUsername string DBPass string DBURL string DBPort string DBName string TableUsers string TableProfiles string TableMatches string TableTokens string }
EnvironmentVariables is a light wrapper for the environment variables required by the database package.
func (*EnvironmentVariables) Load ¶
func (ev *EnvironmentVariables) Load() error
Load attempts to read in all the required environment variables.
type PreparedStatements ¶
type PreparedStatements struct { GetUser string GetAuthExpiry string GetMMR string CreateMatch string CheckMatchValid string GetDisplayName string GetAvatar string SetMatchStart string SetMatchResult string }
PreparedStatements is a light wrapper for all the prepared statements used in this package.
func (*PreparedStatements) Construct ¶
func (p *PreparedStatements) Construct(envvars *EnvironmentVariables)
Construct constructs all the prepared statements for this PreparedStatements object.