gamev1

package
v0.0.0-...-4b884ea Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 17 Imported by: 0

README

Protocol Documentation

Table of Contents

Top

game/v1/game.proto

EndSessionRequest
Field Type Label Description
session Session

EndSessionResponse
Field Type Label Description
session Session

PlayGameRequest
Field Type Label Description
session_id string
player_move Move

PlayGameResponse
Field Type Label Description
computer_move Move
session Session

Session
Field Type Label Description
id string
player_id string
wins int32
losses int32
draws int32

StartSessionRequest
Field Type Label Description
player_id string optional

StartSessionResponse
Field Type Label Description
session Session

Move
Name Number Description
MOVE_UNSPECIFIED 0
MOVE_ROCK 1
MOVE_PAPER 2
MOVE_SCISSORS 3

Top

game/v1/service.proto

GameService
Method Name Request Type Response Type Description
StartSession StartSessionRequest StartSessionResponse
PlayGame PlayGameRequest PlayGameResponse
EndSession EndSessionRequest EndSessionResponse

Scalar Value Types

.proto Type Notes C++ Java Python Go C# PHP Ruby
double double double float float64 double float Float
float float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)

Documentation

Overview

Package gamev1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	GameService_StartSession_FullMethodName = "/game.v1.GameService/StartSession"
	GameService_PlayGame_FullMethodName     = "/game.v1.GameService/PlayGame"
	GameService_EndSession_FullMethodName   = "/game.v1.GameService/EndSession"
)

Variables

View Source
var (
	Move_name = map[int32]string{
		0: "MOVE_UNSPECIFIED",
		1: "MOVE_ROCK",
		2: "MOVE_PAPER",
		3: "MOVE_SCISSORS",
	}
	Move_value = map[string]int32{
		"MOVE_UNSPECIFIED": 0,
		"MOVE_ROCK":        1,
		"MOVE_PAPER":       2,
		"MOVE_SCISSORS":    3,
	}
)

Enum value maps for Move.

View Source
var File_game_v1_game_proto protoreflect.FileDescriptor
View Source
var File_game_v1_service_proto protoreflect.FileDescriptor
View Source
var GameService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "game.v1.GameService",
	HandlerType: (*GameServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "StartSession",
			Handler:    _GameService_StartSession_Handler,
		},
		{
			MethodName: "PlayGame",
			Handler:    _GameService_PlayGame_Handler,
		},
		{
			MethodName: "EndSession",
			Handler:    _GameService_EndSession_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "game/v1/service.proto",
}

GameService_ServiceDesc is the grpc.ServiceDesc for GameService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterGameServiceHandler

func RegisterGameServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterGameServiceHandler registers the http handlers for service GameService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterGameServiceHandlerClient

func RegisterGameServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GameServiceClient) error

RegisterGameServiceHandlerClient registers the http handlers for service GameService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GameServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GameServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "GameServiceClient" to call the correct interceptors.

func RegisterGameServiceHandlerFromEndpoint

func RegisterGameServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterGameServiceHandlerFromEndpoint is same as RegisterGameServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterGameServiceHandlerServer

func RegisterGameServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GameServiceServer) error

RegisterGameServiceHandlerServer registers the http handlers for service GameService to "mux". UnaryRPC :call GameServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGameServiceHandlerFromEndpoint instead.

func RegisterGameServiceServer

func RegisterGameServiceServer(s grpc.ServiceRegistrar, srv GameServiceServer)

Types

type EndSessionRequest

type EndSessionRequest struct {
	Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
	// contains filtered or unexported fields
}

func (*EndSessionRequest) Descriptor deprecated

func (*EndSessionRequest) Descriptor() ([]byte, []int)

Deprecated: Use EndSessionRequest.ProtoReflect.Descriptor instead.

func (*EndSessionRequest) GetSession

func (x *EndSessionRequest) GetSession() *Session

func (*EndSessionRequest) ProtoMessage

func (*EndSessionRequest) ProtoMessage()

func (*EndSessionRequest) ProtoReflect

func (x *EndSessionRequest) ProtoReflect() protoreflect.Message

func (*EndSessionRequest) Reset

func (x *EndSessionRequest) Reset()

func (*EndSessionRequest) String

func (x *EndSessionRequest) String() string

type EndSessionResponse

type EndSessionResponse struct {
	Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
	// contains filtered or unexported fields
}

func (*EndSessionResponse) Descriptor deprecated

func (*EndSessionResponse) Descriptor() ([]byte, []int)

Deprecated: Use EndSessionResponse.ProtoReflect.Descriptor instead.

func (*EndSessionResponse) GetSession

func (x *EndSessionResponse) GetSession() *Session

func (*EndSessionResponse) ProtoMessage

func (*EndSessionResponse) ProtoMessage()

func (*EndSessionResponse) ProtoReflect

func (x *EndSessionResponse) ProtoReflect() protoreflect.Message

func (*EndSessionResponse) Reset

func (x *EndSessionResponse) Reset()

func (*EndSessionResponse) String

func (x *EndSessionResponse) String() string

type GameServiceClient

type GameServiceClient interface {
	StartSession(ctx context.Context, in *StartSessionRequest, opts ...grpc.CallOption) (*StartSessionResponse, error)
	PlayGame(ctx context.Context, in *PlayGameRequest, opts ...grpc.CallOption) (*PlayGameResponse, error)
	EndSession(ctx context.Context, in *EndSessionRequest, opts ...grpc.CallOption) (*EndSessionResponse, error)
}

GameServiceClient is the client API for GameService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type GameServiceServer

type GameServiceServer interface {
	StartSession(context.Context, *StartSessionRequest) (*StartSessionResponse, error)
	PlayGame(context.Context, *PlayGameRequest) (*PlayGameResponse, error)
	EndSession(context.Context, *EndSessionRequest) (*EndSessionResponse, error)
	// contains filtered or unexported methods
}

GameServiceServer is the server API for GameService service. All implementations must embed UnimplementedGameServiceServer for forward compatibility

type Move

type Move int32
const (
	Move_MOVE_UNSPECIFIED Move = 0
	Move_MOVE_ROCK        Move = 1
	Move_MOVE_PAPER       Move = 2
	Move_MOVE_SCISSORS    Move = 3
)

func (Move) Descriptor

func (Move) Descriptor() protoreflect.EnumDescriptor

func (Move) Enum

func (x Move) Enum() *Move

func (Move) EnumDescriptor deprecated

func (Move) EnumDescriptor() ([]byte, []int)

Deprecated: Use Move.Descriptor instead.

func (Move) Number

func (x Move) Number() protoreflect.EnumNumber

func (Move) String

func (x Move) String() string

func (Move) Type

func (Move) Type() protoreflect.EnumType

type PlayGameRequest

type PlayGameRequest struct {
	SessionId  string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
	PlayerMove Move   `protobuf:"varint,2,opt,name=player_move,json=playerMove,proto3,enum=game.v1.Move" json:"player_move,omitempty"`
	// contains filtered or unexported fields
}

func (*PlayGameRequest) Descriptor deprecated

func (*PlayGameRequest) Descriptor() ([]byte, []int)

Deprecated: Use PlayGameRequest.ProtoReflect.Descriptor instead.

func (*PlayGameRequest) GetPlayerMove

func (x *PlayGameRequest) GetPlayerMove() Move

func (*PlayGameRequest) GetSessionId

func (x *PlayGameRequest) GetSessionId() string

func (*PlayGameRequest) ProtoMessage

func (*PlayGameRequest) ProtoMessage()

func (*PlayGameRequest) ProtoReflect

func (x *PlayGameRequest) ProtoReflect() protoreflect.Message

func (*PlayGameRequest) Reset

func (x *PlayGameRequest) Reset()

func (*PlayGameRequest) String

func (x *PlayGameRequest) String() string

type PlayGameResponse

type PlayGameResponse struct {
	ComputerMove Move     `protobuf:"varint,1,opt,name=computer_move,json=computerMove,proto3,enum=game.v1.Move" json:"computer_move,omitempty"`
	Session      *Session `protobuf:"bytes,2,opt,name=session,proto3" json:"session,omitempty"`
	// contains filtered or unexported fields
}

func (*PlayGameResponse) Descriptor deprecated

func (*PlayGameResponse) Descriptor() ([]byte, []int)

Deprecated: Use PlayGameResponse.ProtoReflect.Descriptor instead.

func (*PlayGameResponse) GetComputerMove

func (x *PlayGameResponse) GetComputerMove() Move

func (*PlayGameResponse) GetSession

func (x *PlayGameResponse) GetSession() *Session

func (*PlayGameResponse) ProtoMessage

func (*PlayGameResponse) ProtoMessage()

func (*PlayGameResponse) ProtoReflect

func (x *PlayGameResponse) ProtoReflect() protoreflect.Message

func (*PlayGameResponse) Reset

func (x *PlayGameResponse) Reset()

func (*PlayGameResponse) String

func (x *PlayGameResponse) String() string

type Session

type Session struct {
	Id       string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	PlayerId string `protobuf:"bytes,2,opt,name=player_id,json=playerId,proto3" json:"player_id,omitempty"`
	Wins     int32  `protobuf:"varint,3,opt,name=wins,proto3" json:"wins,omitempty"`
	Losses   int32  `protobuf:"varint,4,opt,name=losses,proto3" json:"losses,omitempty"`
	Draws    int32  `protobuf:"varint,5,opt,name=draws,proto3" json:"draws,omitempty"`
	// contains filtered or unexported fields
}

func (*Session) Descriptor deprecated

func (*Session) Descriptor() ([]byte, []int)

Deprecated: Use Session.ProtoReflect.Descriptor instead.

func (*Session) GetDraws

func (x *Session) GetDraws() int32

func (*Session) GetId

func (x *Session) GetId() string

func (*Session) GetLosses

func (x *Session) GetLosses() int32

func (*Session) GetPlayerId

func (x *Session) GetPlayerId() string

func (*Session) GetWins

func (x *Session) GetWins() int32

func (*Session) ProtoMessage

func (*Session) ProtoMessage()

func (*Session) ProtoReflect

func (x *Session) ProtoReflect() protoreflect.Message

func (*Session) Reset

func (x *Session) Reset()

func (*Session) String

func (x *Session) String() string

type StartSessionRequest

type StartSessionRequest struct {
	PlayerId *string `protobuf:"bytes,1,opt,name=player_id,json=playerId,proto3,oneof" json:"player_id,omitempty"`
	// contains filtered or unexported fields
}

func (*StartSessionRequest) Descriptor deprecated

func (*StartSessionRequest) Descriptor() ([]byte, []int)

Deprecated: Use StartSessionRequest.ProtoReflect.Descriptor instead.

func (*StartSessionRequest) GetPlayerId

func (x *StartSessionRequest) GetPlayerId() string

func (*StartSessionRequest) ProtoMessage

func (*StartSessionRequest) ProtoMessage()

func (*StartSessionRequest) ProtoReflect

func (x *StartSessionRequest) ProtoReflect() protoreflect.Message

func (*StartSessionRequest) Reset

func (x *StartSessionRequest) Reset()

func (*StartSessionRequest) String

func (x *StartSessionRequest) String() string

type StartSessionResponse

type StartSessionResponse struct {
	Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
	// contains filtered or unexported fields
}

func (*StartSessionResponse) Descriptor deprecated

func (*StartSessionResponse) Descriptor() ([]byte, []int)

Deprecated: Use StartSessionResponse.ProtoReflect.Descriptor instead.

func (*StartSessionResponse) GetSession

func (x *StartSessionResponse) GetSession() *Session

func (*StartSessionResponse) ProtoMessage

func (*StartSessionResponse) ProtoMessage()

func (*StartSessionResponse) ProtoReflect

func (x *StartSessionResponse) ProtoReflect() protoreflect.Message

func (*StartSessionResponse) Reset

func (x *StartSessionResponse) Reset()

func (*StartSessionResponse) String

func (x *StartSessionResponse) String() string

type UnimplementedGameServiceServer

type UnimplementedGameServiceServer struct {
}

UnimplementedGameServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedGameServiceServer) EndSession

func (UnimplementedGameServiceServer) PlayGame

func (UnimplementedGameServiceServer) StartSession

type UnsafeGameServiceServer

type UnsafeGameServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeGameServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GameServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

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