sqlstore

package
v0.0.0-...-b90c408 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store represents an SQL store.

func NewSQLStore

func NewSQLStore(url string) (*Store, error)

NewSQLStore returns a new store using a postgres database.

func (*Store) CreateGame

func (s *Store) CreateGame(
	ctx context.Context, g *pb.Game, frames []*pb.GameFrame) error

CreateGame will insert a game with the default game frames.

func (*Store) GetGame

func (s *Store) GetGame(c context.Context, id string) (*pb.Game, error)

GetGame will fetch the game.

func (*Store) ListGameFrames

func (s *Store) ListGameFrames(ctx context.Context, id string, limit, offset int) ([]*pb.GameFrame, error)

ListGameFrames will list frames by an offset and limit, it supports negative offset.

func (*Store) Lock

func (s *Store) Lock(ctx context.Context, key, token string) (string, error)

Lock will lock a specific game, returning a token that must be used to write frames to the game.

func (*Store) PopGameID

func (s *Store) PopGameID(ctx context.Context) (string, error)

PopGameID returns a new game that is unlocked and running. Workers call this method through the controller to find games to process.

func (*Store) PushGameFrame

func (s *Store) PushGameFrame(
	ctx context.Context, id string, t *pb.GameFrame) error

PushGameFrame will push a game frame onto the list of frames.

func (*Store) SetGameStatus

func (s *Store) SetGameStatus(
	ctx context.Context, id string, status rules.GameStatus) error

SetGameStatus is used to set a specific game status. This operation should be atomic.

func (*Store) Unlock

func (s *Store) Unlock(ctx context.Context, key, token string) error

Unlock will unlock a game if it is locked and the token used to lock it is correct.

Jump to

Keyboard shortcuts

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