datastore

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGameStoreNotEnabled = fmt.Errorf("game store is not enabled")
	ErrGameStoreNotFound   = fmt.Errorf("no game found in game store")
	ErrGameStoreConnection = fmt.Errorf("failed to connect to game store")
	ErrGameStoreSelect     = fmt.Errorf("failed to select from game store")
	ErrGameStoreInsert     = fmt.Errorf("failed to insert into game store")
)

Functions

This section is empty.

Types

type CockroachClient added in v1.3.0

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

func NewCockroachClient added in v1.3.0

func NewCockroachClient(config *CockroachConfig) (*CockroachClient, error)

func (*CockroachClient) Close added in v1.3.0

func (c *CockroachClient) Close(ctx context.Context) error

func (*CockroachClient) GetGame added in v1.3.0

func (c *CockroachClient) GetGame(gameKey, gameID string) (*Game, error)

func (*CockroachClient) GetStats added in v1.3.0

func (c *CockroachClient) GetStats(games []string) (*Stats, error)

func (*CockroachClient) Store added in v1.3.0

func (c *CockroachClient) Store(game *Game) error

type CockroachConfig added in v1.3.0

type CockroachConfig struct {
	Enabled  bool
	Host     string
	Username string
	Password string
	Database string
	SSLMode  string
}

func (*CockroachConfig) GetURL added in v1.3.0

func (c *CockroachConfig) GetURL() string

type DatastoreConfig

type DatastoreConfig struct {
	Cockroach CockroachConfig
}

type Game added in v1.3.0

type Game struct {
	GameKey   string    `json:"game_key"`
	GameID    string    `json:"game_id"`
	BGN       *bgn.Game `json:"bgn"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	PlayCount int       `json:"play_count"` // multiple games could have been played under the same game id
}

type GameStore added in v1.3.0

type GameStore interface {
	GetGame(gameKey, gameID string) (*Game, error)
	GetStats(games []string) (*Stats, error)
	Store(game *Game) error
	Close(ctx context.Context) error
}

GameStore stores games into long term storage

type Stats added in v1.3.0

type Stats struct {
	GamesCreated map[string]int
	GamesPlayed  map[string]int
}

Jump to

Keyboard shortcuts

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