redis

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultDataTTL = time.Hour * 24 * 30

DefaultDataTTL is how long data will be kept before redis evicts it

View Source
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

func NewStore(connectURL string) (*Store, error)

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

func (rs *Store) Close() error

Close closes the underlying redis client. see: github.com/go-redis/redis/Client.go

func (*Store) CreateGame

func (rs *Store) CreateGame(c context.Context, game *pb.Game, frames []*pb.GameFrame) error

CreateGame will insert a game with the default game frames.

func (*Store) GameQueueLength added in v0.2.17

func (rs *Store) GameQueueLength(c context.Context) (int, int, error)

func (*Store) GetGame

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

GetGame will fetch the game.

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

func (rs *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 (rs *Store) PopGameID(c 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 (rs *Store) PushGameFrame(c context.Context, id string, t *pb.GameFrame) error

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

func (*Store) SetGameStatus

func (rs *Store) SetGameStatus(c 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 (rs *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