Documentation ¶
Overview ¶
Package gamev1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterGameServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterGameServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GameServiceClient) error
- func RegisterGameServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterGameServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GameServiceServer) error
- func RegisterGameServiceServer(s grpc.ServiceRegistrar, srv GameServiceServer)
- type EndSessionRequest
- type EndSessionResponse
- func (*EndSessionResponse) Descriptor() ([]byte, []int)deprecated
- func (x *EndSessionResponse) GetSession() *Session
- func (*EndSessionResponse) ProtoMessage()
- func (x *EndSessionResponse) ProtoReflect() protoreflect.Message
- func (x *EndSessionResponse) Reset()
- func (x *EndSessionResponse) String() string
- type GameServiceClient
- type GameServiceServer
- type Move
- type PlayGameRequest
- func (*PlayGameRequest) Descriptor() ([]byte, []int)deprecated
- func (x *PlayGameRequest) GetPlayerMove() Move
- func (x *PlayGameRequest) GetSessionId() string
- func (*PlayGameRequest) ProtoMessage()
- func (x *PlayGameRequest) ProtoReflect() protoreflect.Message
- func (x *PlayGameRequest) Reset()
- func (x *PlayGameRequest) String() string
- type PlayGameResponse
- func (*PlayGameResponse) Descriptor() ([]byte, []int)deprecated
- func (x *PlayGameResponse) GetComputerMove() Move
- func (x *PlayGameResponse) GetSession() *Session
- func (*PlayGameResponse) ProtoMessage()
- func (x *PlayGameResponse) ProtoReflect() protoreflect.Message
- func (x *PlayGameResponse) Reset()
- func (x *PlayGameResponse) String() string
- type Session
- func (*Session) Descriptor() ([]byte, []int)deprecated
- func (x *Session) GetDraws() int32
- func (x *Session) GetId() string
- func (x *Session) GetLosses() int32
- func (x *Session) GetPlayerId() string
- func (x *Session) GetWins() int32
- func (*Session) ProtoMessage()
- func (x *Session) ProtoReflect() protoreflect.Message
- func (x *Session) Reset()
- func (x *Session) String() string
- type StartSessionRequest
- func (*StartSessionRequest) Descriptor() ([]byte, []int)deprecated
- func (x *StartSessionRequest) GetPlayerId() string
- func (*StartSessionRequest) ProtoMessage()
- func (x *StartSessionRequest) ProtoReflect() protoreflect.Message
- func (x *StartSessionRequest) Reset()
- func (x *StartSessionRequest) String() string
- type StartSessionResponse
- func (*StartSessionResponse) Descriptor() ([]byte, []int)deprecated
- func (x *StartSessionResponse) GetSession() *Session
- func (*StartSessionResponse) ProtoMessage()
- func (x *StartSessionResponse) ProtoReflect() protoreflect.Message
- func (x *StartSessionResponse) Reset()
- func (x *StartSessionResponse) String() string
- type UnimplementedGameServiceServer
- func (UnimplementedGameServiceServer) EndSession(context.Context, *EndSessionRequest) (*EndSessionResponse, error)
- func (UnimplementedGameServiceServer) PlayGame(context.Context, *PlayGameRequest) (*PlayGameResponse, error)
- func (UnimplementedGameServiceServer) StartSession(context.Context, *StartSessionRequest) (*StartSessionResponse, error)
- type UnsafeGameServiceServer
Constants ¶
const ( GameService_StartSession_FullMethodName = "/game.v1.GameService/StartSession" GameService_PlayGame_FullMethodName = "/game.v1.GameService/PlayGame" GameService_EndSession_FullMethodName = "/game.v1.GameService/EndSession" )
Variables ¶
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.
var File_game_v1_game_proto protoreflect.FileDescriptor
var File_game_v1_service_proto protoreflect.FileDescriptor
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.
func NewGameServiceClient ¶
func NewGameServiceClient(cc grpc.ClientConnInterface) GameServiceClient
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
func (Move) Descriptor ¶
func (Move) Descriptor() protoreflect.EnumDescriptor
func (Move) EnumDescriptor
deprecated
func (Move) Number ¶
func (x Move) Number() protoreflect.EnumNumber
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) GetPlayerId ¶
func (*Session) ProtoMessage ¶
func (*Session) ProtoMessage()
func (*Session) ProtoReflect ¶
func (x *Session) ProtoReflect() protoreflect.Message
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) EndSession(context.Context, *EndSessionRequest) (*EndSessionResponse, error)
func (UnimplementedGameServiceServer) PlayGame ¶
func (UnimplementedGameServiceServer) PlayGame(context.Context, *PlayGameRequest) (*PlayGameResponse, error)
func (UnimplementedGameServiceServer) StartSession ¶
func (UnimplementedGameServiceServer) StartSession(context.Context, *StartSessionRequest) (*StartSessionResponse, error)
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.