dbhist

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: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//TimeFormat is the RFC3339Nano with trailing zeros.
	TimeFormat = "2006-01-02T15:04:05.000000000Z07:00"
)

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(hist *game.Hist) (b []byte)

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

func KeyPlayersTime

func KeyPlayersTime(hist *game.Hist) (key []byte)

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

func KeyTimePlayers

func KeyTimePlayers(hist *game.Hist) (key []byte)

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

Types

type Db

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

Db is a battleline database

func New

func New(keyf func(*game.Hist) []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)

BackupHandleFunc handles http back up requests.

func (*Db) Close

func (bdb *Db) Close() error

Close the bolt database

func (*Db) Delete

func (bdb *Db) Delete(key []byte) (err error)

Delete deletes a key from database.

func (*Db) Get

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

Get fetches a game history from the database.

func (*Db) Gets

func (bdb *Db) Gets(keys [][]byte) (hists []*game.Hist, err error)

Gets fetches multiple games from database.

func (*Db) Init

func (bdb *Db) Init() error

Init inits the battleline bucket if does not exist.

func (*Db) Key

func (bdb *Db) Key(hist *game.Hist) []byte

Key returns the key.

func (*Db) MaxFetchNo

func (bdb *Db) MaxFetchNo() int

MaxFetchNo returns the max. number of records fetched in search.

func (*Db) Put

func (bdb *Db) Put(hist *game.Hist) (err error)

Put adds a history of a game to the bucket.

func (*Db) Puts

func (bdb *Db) Puts(hists []*game.Hist) (err error)

Puts adds muliple histories to bucket.

func (*Db) ScannPrefix

func (bdb *Db) ScannPrefix(
	filterFunc func(hist *game.Hist) bool,
	prefix []byte) (hists []*game.Hist, isMaxFetch bool, err error)

ScannPrefix makes a prefix scann.

func (*Db) ScannStartEnd

func (bdb *Db) ScannStartEnd(
	filterFunc func(game *game.Hist) bool,
	start []byte,
	end []byte) (hists []*game.Hist, 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(
	filterFunc func(hist *game.Hist) bool,
	startKey []byte) (hists []*game.Hist, nextKey []byte, err error)

Search the database from the start key if next key is not empty more enteries exist,than could be loaded

Jump to

Keyboard shortcuts

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