store

package
v0.0.0-...-694ebd1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package store provides database functionalities

Index

Constants

This section is empty.

Variables

View Source
var (
	// StoreGameListKey is sub-key name placing full game list of a platform
	StoreGameListKey = "index"
)

Functions

func Decode

func Decode(data []byte, object interface{}) error

Decode from byte slice to an object

func Encode

func Encode(object interface{}) ([]byte, error)

Encode an object to byte slice

Types

type BoltStore

type BoltStore struct {
	LogLevel string
	Buckets  []string
	// contains filtered or unexported fields
}

BoltStore represents a bolt store for game database

func NewBoltStore

func NewBoltStore(cfg Config) (*BoltStore, error)

NewBoltStore creates a bolt store

func (*BoltStore) Close

func (bs *BoltStore) Close() error

Close badger store

func (*BoltStore) GetGameList

func (bs *BoltStore) GetGameList(platform string) (map[int]string, error)

GetGameList index from bolt store

func (*BoltStore) GetGameRecord

func (bs *BoltStore) GetGameRecord(platform string, subid string) (*GameRecord, error)

GetGameRecord from bolt store

func (*BoltStore) GetSavedGameList

func (bs *BoltStore) GetSavedGameList(platform string) (map[int]string, error)

GetSavedGameList from bolt store

func (*BoltStore) SaveGameList

func (bs *BoltStore) SaveGameList(platform string, games map[int]string) error

SaveGameList to badger store

func (*BoltStore) SaveGameRecord

func (bs *BoltStore) SaveGameRecord(platform string, subid string, r GameRecord) error

SaveGameRecord to badger store

type Config

type Config struct {
	Database  string
	StorePath string
	Buckets   []string
}

Config is the configuration struct of seeker

type DummyStore

type DummyStore struct {
	LogLevel string
}

DummyStore represents a dummy store for game database

func NewDummyStore

func NewDummyStore(cfg Config) (*DummyStore, error)

NewDummyStore creates a dummy store

func (*DummyStore) Close

func (ds *DummyStore) Close() error

Close dummy store

func (*DummyStore) GetGameList

func (ds *DummyStore) GetGameList(platform string) (map[int]string, error)

GetGameList from dummy store, pretend to have most of games

func (*DummyStore) GetSavedGameList

func (ds *DummyStore) GetSavedGameList(platform string) (map[int]string, error)

GetSavedGameList from dummy store, pretend to have most of games

func (*DummyStore) SaveGameList

func (ds *DummyStore) SaveGameList(platform string, games map[int]string) error

SaveGameList to dummy store

func (*DummyStore) SaveGameRecord

func (ds *DummyStore) SaveGameRecord(platform string, subid string, r GameRecord) error

SaveGameRecord to dummy store

type GameRecord

type GameRecord struct {
	Name        string
	ID          int
	RequiredAge int
	Description string
	About       string
	Languages   string
	Developers  []string
	Publishers  []string
}

GameRecord represents detailed game information

type GameStore

type GameStore interface {
	Close() error
	SaveGameList(platform string, games map[int]string) error
	GetGameList(platform string) (map[int]string, error)
	GetSavedGameList(platform string) (map[int]string, error)
	SaveGameRecord(platform string, subid string, r GameRecord) error
}

GameStore represents general interfaces of store package. Implementations are corresponding to different databases.

func New

func New(cfg *Config) (GameStore, error)

New creates a new GameStore according to configuration

Jump to

Keyboard shortcuts

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