storage

package
v0.0.0-...-c84f994 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MongoHost       string `split_words:"true" required:"true"`
	MongoPort       string `split_words:"true" required:"true"`
	MongoName       string `split_words:"true" required:"true"`
	MongoUser       string `split_words:"true" required:"true"`
	MongoPass       string `split_words:"true" required:"false"`
	MongoCollection string `split_words:"true" required:"true"`
}

Config describes db connection information

type Manager

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

Manager provides access to collections and predefined CRUD functionality.

func New

func New(config Config) (mgr *Manager, err error)

New sets up a MongoDB connection and ensures it is ready to use

func (*Manager) ArchiveServer

func (mgr *Manager) ArchiveServer(address string) (err error)

ArchiveServer marks a server as inactive by setting the `Active` field to false

func (*Manager) GetActiveServers

func (mgr *Manager) GetActiveServers() (servers int, err error)

GetActiveServers returns the number of active servers

func (*Manager) GetInactiveServers

func (mgr *Manager) GetInactiveServers() (servers int, err error)

GetInactiveServers returns the number of inactive servers

func (*Manager) GetServer

func (mgr *Manager) GetServer(address string) (server types.Server, found bool, err error)

GetServer looks up a server via the address

func (*Manager) GetServers

func (mgr *Manager) GetServers(pageNum int, pageSize types.PageSize, sort types.SortOrder, by types.SortColumn, filters []types.FilterAttribute) (servers []types.ServerCore, err error)

GetServers returns a slice of Core objects

func (*Manager) GetTotalPlayers

func (mgr *Manager) GetTotalPlayers() (players int, err error)

GetTotalPlayers returns the number of total players

func (*Manager) LoadAllAddresses

func (mgr *Manager) LoadAllAddresses() (result []string, err error)

LoadAllAddresses loads all addresses from the database as a slice of strings for synchronisation with the QueryDaemon.

func (*Manager) RemoveServer

func (mgr *Manager) RemoveServer(address string) (err error)

RemoveServer deletes a server from the database

func (*Manager) UpsertServer

func (mgr *Manager) UpsertServer(server types.Server) (err error)

UpsertServer creates or updates a server object in the database, implicitly sets `Active` to true

Jump to

Keyboard shortcuts

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