db

package
v0.0.0-...-555310e Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDBs

func InitDBs()

InitDBs initializes the geolocation and server information databases for re-use across server list builds. Panics on failure to initialize.

Types

type CDB

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

CDB represents a database containing geolocation information.

var CountryDB *CDB

CountryDB is a package-level variable that contains a country geoelocation database connection. It is initialized once for re-usability when building server lists.

func OpenCountryDB

func OpenCountryDB() (*CDB, error)

OpenCountryDB opens the country lookup database for reading. The caller of this function will be responsinble for calling .Close().

func (*CDB) Close

func (cdb *CDB) Close()

Close closes the country geolocation database.

func (*CDB) GetCountryInfo

func (cdb *CDB) GetCountryInfo(ch chan<- models.DbCountry, ipstr string)

GetCountryInfo attempts to retrieve the country information for a given IP, returning the result as a country model object over the corresponding result channel.

type SDB

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

SDB represents a database containing the server ID and game information.

var ServerDB *SDB

ServerDB is a package-level variable that contains a server information database connection. It is initialized once for re-usability when building server lists.

func OpenServerDB

func OpenServerDB() (*SDB, error)

OpenServerDB Opens a database connection to the server database file or if that file does not exists, creates it and then opens a database connection to it.

func (*SDB) AddServersToDB

func (sdb *SDB) AddServersToDB(hostsgames map[string]string)

AddServersToDB inserts a specified host and port with its game name into the server database.

func (*SDB) Close

func (sdb *SDB) Close()

Close closes the server database's underlying connection.

func (*SDB) GetHostsAndGameFromIDAPIQuery

func (sdb *SDB) GetHostsAndGameFromIDAPIQuery(result chan map[string]string,
	ids []string)

GetHostsAndGameFromIDAPIQuery Retrieves the hosts and game names from the server database file in response to a user-specified API query for a given set of server ID numbers. Sends the results over a channel consisting of a host to game name string mapping.

func (*SDB) GetIDsAPIQuery

func (sdb *SDB) GetIDsAPIQuery(result chan *models.DbServerID, hosts []string)

GetIDsAPIQuery Retrieves the server ID numbers, hosts, and game name for a given set of hosts (represented by query string values) from the server database file in response to a query from the API. Sends the results over a DbServerID channel for consumption.

func (*SDB) GetIDsForServerList

func (sdb *SDB) GetIDsForServerList(result chan map[string]int64,
	hosts map[string]string)

GetIDsForServerList retrieves the server ID numbers for a given set of hosts, from the server database file, in response to a request to build the master server detail list or the list of server details in response to a request coming in over the API. It sends its results over a map channel consisting of a host to id mapping.

Jump to

Keyboard shortcuts

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