Documentation ¶
Index ¶
- Constants
- type Store
- func (rs *Store) Close() error
- func (rs *Store) CreateGame(c context.Context, game *pb.Game, frames []*pb.GameFrame) error
- func (rs *Store) GameQueueLength(c context.Context) (int, int, error)
- func (rs *Store) GetGame(c context.Context, id string) (*pb.Game, error)
- func (rs *Store) ListGameFrames(c context.Context, id string, limit, offset int) ([]*pb.GameFrame, error)
- func (rs *Store) Lock(ctx context.Context, key, token string) (string, error)
- func (rs *Store) PopGameID(c context.Context) (string, error)
- func (rs *Store) PushGameFrame(c context.Context, id string, t *pb.GameFrame) error
- func (rs *Store) SetGameStatus(c context.Context, id string, status rules.GameStatus) error
- func (rs *Store) Unlock(ctx context.Context, key, token string) error
Constants ¶
const DefaultDataTTL = time.Hour * 24 * 30
DefaultDataTTL is how long data will be kept before redis evicts it
const DefaultLockExpiry = time.Minute
DefaultLockExpiry is how long locks are kept around for
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an implementation of the controller.Store interface
func NewStore ¶
NewStore will create a new instance of an underlying redis client, so it should not be re-created across "threads" - connectURL see: github.com/go-redis/redis/options.go for URL specifics The underlying redis client will be immediately tested for connectivity, so don't call this until you know redis can connect. Returns a new instance OR an error if unable (meaning an issue connecting to your redis URL)
func (*Store) Close ¶
Close closes the underlying redis client. see: github.com/go-redis/redis/Client.go
func (*Store) CreateGame ¶
CreateGame will insert a game with the default game frames.
func (*Store) GameQueueLength ¶ added in v0.2.17
func (*Store) ListGameFrames ¶
func (rs *Store) ListGameFrames(c 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 ¶
Lock will lock a specific game, returning a token that must be used to write frames to the game.
func (*Store) PopGameID ¶
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 ¶
PushGameFrame will push a game frame onto the list of frames.
func (*Store) SetGameStatus ¶
SetGameStatus is used to set a specific game status. This operation should be atomic.