hexzmem

package
v0.0.0-...-3e36cfb Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisClient

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

func NewRedisClient

func NewRedisClient(config *RedisClientConfig) (*RedisClient, error)

func (*RedisClient) DeleteGame

func (c *RedisClient) DeleteGame(ctx context.Context, gameId string) error

func (*RedisClient) ListRecentGames

func (c *RedisClient) ListRecentGames(ctx context.Context, limit int) ([]*pb.GameInfo, error)

func (*RedisClient) LoginPlayer

func (c *RedisClient) LoginPlayer(ctx context.Context, playerId hexz.PlayerId, name string) error

func (*RedisClient) LookupGame

func (c *RedisClient) LookupGame(ctx context.Context, gameId string) (*pb.GameState, error)

func (*RedisClient) LookupPlayer

func (c *RedisClient) LookupPlayer(ctx context.Context, playerId hexz.PlayerId) (hexz.Player, error)

func (*RedisClient) Ping

func (c *RedisClient) Ping() error

func (*RedisClient) Publish

func (c *RedisClient) Publish(ctx context.Context, gameId string, message string) error

Sends a message to the channel for the given game. Returns the number of subscribers that received the message.

func (*RedisClient) StoreNewGame

func (c *RedisClient) StoreNewGame(ctx context.Context, s *pb.GameState) (bool, error)

Stores the given game state in Redis, unless a game with the same ID already exists. This method updates the Modified fields of the game state.

func (*RedisClient) Subscribe

func (c *RedisClient) Subscribe(ctx context.Context, gameId string, ch chan<- string)

func (*RedisClient) UpdateGame

func (c *RedisClient) UpdateGame(ctx context.Context, s *pb.GameState) error

Stores the given game state in Redis, overwriting any existing game with the same ID. This method updates the Seqnum and Modified fields of the game state.

type RedisClientConfig

type RedisClientConfig struct {
	Addr     string
	LoginTTL time.Duration
	GameTTL  time.Duration
	DB       int // Production should always use 0, 1 is for testing.
}

type RemotePlayerStore

type RemotePlayerStore struct {
	*RedisClient
}

RemotePlayerStore is an interface adapter that lets RedisClient implement PlayerStore.

func (*RemotePlayerStore) Login

func (s *RemotePlayerStore) Login(ctx context.Context, playerId hexz.PlayerId, name string) error

func (*RemotePlayerStore) Lookup

func (s *RemotePlayerStore) Lookup(ctx context.Context, playerId hexz.PlayerId) (hexz.Player, error)

Jump to

Keyboard shortcuts

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