server

package module
v0.0.0-...-e42abf7 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

README

A go program to serve tronimoes games.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, port string, s *grpc.Server) error

Types

type Games

type Games interface {
	WriteGame(ctx context.Context, gm *spb.Game) error
	ReadGame(ctx context.Context, id string) (*spb.Game, error)
	WriteBoard(ctx context.Context, id string, b *tpb.Board) error
	ReadBoard(ctx context.Context, id string) (*tpb.Board, error)
}

type InMemoryGames

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

func (*InMemoryGames) ReadBoard

func (g *InMemoryGames) ReadBoard(ctx context.Context, id string) (*tpb.Board, error)

func (*InMemoryGames) ReadGame

func (g *InMemoryGames) ReadGame(ctx context.Context, id string) (*spb.Game, error)

func (*InMemoryGames) WriteBoard

func (g *InMemoryGames) WriteBoard(ctx context.Context, id string, b *tpb.Board) error

func (*InMemoryGames) WriteGame

func (g *InMemoryGames) WriteGame(ctx context.Context, gm *spb.Game) error

type InMemoryOperations

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

func (*InMemoryOperations) NewOperation

func (o *InMemoryOperations) NewOperation(ctx context.Context) (*spb.Operation, error)

func (*InMemoryOperations) ReadOperation

func (o *InMemoryOperations) ReadOperation(ctx context.Context, id string) (*spb.Operation, error)

func (*InMemoryOperations) WriteOperation

func (o *InMemoryOperations) WriteOperation(ctx context.Context, op *spb.Operation) error

type InMemoryQueue

type InMemoryQueue struct {
	Games      Games
	Operations Operations
	Rounds     *Rounds
	// contains filtered or unexported fields
}

func (*InMemoryQueue) AddPlayer

func (q *InMemoryQueue) AddPlayer(ctx context.Context, playerID string, req *spb.CreateGameRequest, operationID string) error

func (*InMemoryQueue) MakeNextGame

func (q *InMemoryQueue) MakeNextGame(ctx context.Context) error

type Operations

type Operations interface {
	WriteOperation(ctx context.Context, op *spb.Operation) error
	ReadOperation(ctx context.Context, id string) (*spb.Operation, error)
	NewOperation(ctx context.Context) (*spb.Operation, error)
}

type Queue

type Queue interface {
	AddPlayer(ctx context.Context, playerID string, req *spb.CreateGameRequest, operationID string) error
	MakeNextGame(ctx context.Context) error
}

type Rounds

type Rounds struct {
	Games Games
}

func (*Rounds) StartRound

func (r *Rounds) StartRound(ctx context.Context, g *spb.Game) error

type Tronimoes

type Tronimoes struct {
	Operations Operations
	Queue      Queue
	Games      Games
	Rounds     *Rounds
}

func (*Tronimoes) CreateAccessToken

func (t *Tronimoes) CreateAccessToken(ctx context.Context, req *spb.CreateAccessTokenRequest) (*spb.AccessTokenResponse, error)

func (*Tronimoes) CreateGame

func (t *Tronimoes) CreateGame(ctx context.Context, req *spb.CreateGameRequest) (*spb.Operation, error)

func (*Tronimoes) GetBoard

func (t *Tronimoes) GetBoard(ctx context.Context, req *spb.GetBoardRequest) (*tpb.Board, error)

func (*Tronimoes) GetGame

func (t *Tronimoes) GetGame(ctx context.Context, req *spb.GetGameRequest) (*spb.Game, error)

func (*Tronimoes) GetMoves

func (*Tronimoes) GetOperation

func (t *Tronimoes) GetOperation(ctx context.Context, req *spb.GetOperationRequest) (*spb.Operation, error)

func (*Tronimoes) LayTile

func (t *Tronimoes) LayTile(ctx context.Context, req *spb.LayTileRequest) (*tpb.Board, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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