battdb

package
v0.0.0-...-0992052 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyPlayerIds

func KeyPlayerIds(ids [2]int) (key []byte)

KeyPlayerIds define a key as player ids where the smalles player id comes first.

func KeyPlayers

func KeyPlayers(game *bat.Game) (b []byte)

KeyPlayers define a key as player ids where the smalles player id comes first.

func KeyPlayersTime

func KeyPlayersTime(game *bat.Game) (key []byte)

KeyPlayersTime define a key as timestamp 2006-01-02T15:04:05Z07:00 plus player ids where the smalles player id comes first.

func KeyTimePlayers

func KeyTimePlayers(game *bat.Game) (key []byte)

KeyTimePlayers define a key as player ids where the smalles player id comes first plus timestamp 2006-01-02T15:04:05Z07:00.

Types

type Db

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

Db is a battleline database

func New

func New(keyf func(*bat.Game) []byte, db *bolt.DB, maxFetchNo int) *Db

New create a battleline database.

func (*Db) BackupHandleFunc

func (bdb *Db) BackupHandleFunc(w http.ResponseWriter, req *http.Request)

func (*Db) Get

func (bdb *Db) Get(key []byte) (game *bat.Game, err error)

Get fetch a game from the database.

func (*Db) Gets

func (bdb *Db) Gets(keys [][]byte) (games []*bat.Game, err error)

Gets fetch multiple games from database.

func (*Db) Init

func (bdb *Db) Init() error

Init init the battleline bucket if does not exist.

func (*Db) MaxFetchNo

func (bdb *Db) MaxFetchNo() int

func (*Db) Put

func (bdb *Db) Put(game *bat.Game) (key []byte, err error)

Put adds a game to the bucket.

func (*Db) Puts

func (bdb *Db) Puts(games []*bat.Game) (keys [][]byte, err error)

Puts adds muliple games to bucket.

func (*Db) ScannPrefix

func (bdb *Db) ScannPrefix(
	filterF func(game *bat.Game, key []byte) bool,
	prefix []byte) (games []*bat.Game, isMaxFetch bool, err error)

ScannPrefix makes a prefix scann.

func (*Db) ScannStartEnd

func (bdb *Db) ScannStartEnd(
	filterF func(game *bat.Game, key []byte) bool,
	start []byte,
	end []byte) (games []*bat.Game, isMaxFetch bool, err error)

ScannStartEnd scans a interval of keys. The keys must be bytes comparable and the start key must exist.

func (*Db) Search

func (bdb *Db) Search(
	filterF func(game *bat.Game, key []byte) bool) (games []*bat.Game, nextKey []byte, err error)

Search the full database from the last entry. The search stops if the max numbers of records is reach.

func (*Db) SearchLoop

func (bdb *Db) SearchLoop(
	filterF func(game *bat.Game, key []byte) bool,
	startKey []byte) (games []*bat.Game, nextKey []byte, err error)

Search the full database from the last entry. The search stops if the max numbers of records is reach.

Jump to

Keyboard shortcuts

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