edge

package
v0.0.0-...-160e8be Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MPL-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package edge is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var MessageFactory = map[string]func() proto.Message{
	"player":    messageFactory[ResourceType_PLAYER],
	"character": messageFactory[ResourceType_CHARACTER],
}
View Source
var RpgService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "edge.RpgService",
	HandlerType: (*RpgServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ReadPlayer",
			Handler:    _RpgService_ReadPlayer_Handler,
		},
		{
			MethodName: "CreatePlayer",
			Handler:    _RpgService_CreatePlayer_Handler,
		},
		{
			MethodName: "UpdatePlayer",
			Handler:    _RpgService_UpdatePlayer_Handler,
		},
		{
			MethodName: "DeletePlayer",
			Handler:    _RpgService_DeletePlayer_Handler,
		},
		{
			MethodName: "ReadCharacter",
			Handler:    _RpgService_ReadCharacter_Handler,
		},
		{
			MethodName: "CreateCharacter",
			Handler:    _RpgService_CreateCharacter_Handler,
		},
		{
			MethodName: "UpdateCharacter",
			Handler:    _RpgService_UpdateCharacter_Handler,
		},
		{
			MethodName: "DeleteCharacter",
			Handler:    _RpgService_DeleteCharacter_Handler,
		},
		{
			MethodName: "FundCharacter",
			Handler:    _RpgService_FundCharacter_Handler,
		},
		{
			MethodName: "ConductTrade",
			Handler:    _RpgService_ConductTrade_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "edge.proto",
}

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

Functions

func CobraCommand

func CobraCommand(rkcycmd *runner.RkcyCmd) *cobra.Command

func RegisterRpgServiceHandler

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

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

func RegisterRpgServiceHandlerClient

func RegisterRpgServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RpgServiceClient) error

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

func RegisterRpgServiceHandlerFromEndpoint

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

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

func RegisterRpgServiceHandlerServer

func RegisterRpgServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RpgServiceServer) error

RegisterRpgServiceHandlerServer registers the http handlers for service RpgService to "mux". UnaryRPC :call RpgServiceServer 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 RegisterRpgServiceHandlerFromEndpoint instead.

func RegisterRpgServiceServer

func RegisterRpgServiceServer(s grpc.ServiceRegistrar, srv RpgServiceServer)

Types

type CharacterResponse

type CharacterResponse struct {
	Character *pb.Character        `protobuf:"bytes,1,opt,name=character,proto3" json:"character,omitempty"`
	Related   *pb.CharacterRelated `protobuf:"bytes,2,opt,name=related,proto3" json:"related,omitempty"`
	// contains filtered or unexported fields
}

func (*CharacterResponse) Descriptor deprecated

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

Deprecated: Use CharacterResponse.ProtoReflect.Descriptor instead.

func (*CharacterResponse) GetCharacter

func (x *CharacterResponse) GetCharacter() *pb.Character

func (*CharacterResponse) GetRelated

func (x *CharacterResponse) GetRelated() *pb.CharacterRelated

func (*CharacterResponse) ProtoMessage

func (*CharacterResponse) ProtoMessage()

func (*CharacterResponse) ProtoReflect

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

func (*CharacterResponse) Reset

func (x *CharacterResponse) Reset()

func (*CharacterResponse) String

func (x *CharacterResponse) String() string

type PlayerResponse

type PlayerResponse struct {
	Player  *pb.Player        `protobuf:"bytes,1,opt,name=player,proto3" json:"player,omitempty"`
	Related *pb.PlayerRelated `protobuf:"bytes,2,opt,name=related,proto3" json:"related,omitempty"`
	// contains filtered or unexported fields
}

func (*PlayerResponse) Descriptor deprecated

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

Deprecated: Use PlayerResponse.ProtoReflect.Descriptor instead.

func (*PlayerResponse) GetPlayer

func (x *PlayerResponse) GetPlayer() *pb.Player

func (*PlayerResponse) GetRelated

func (x *PlayerResponse) GetRelated() *pb.PlayerRelated

func (*PlayerResponse) ProtoMessage

func (*PlayerResponse) ProtoMessage()

func (*PlayerResponse) ProtoReflect

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

func (*PlayerResponse) Reset

func (x *PlayerResponse) Reset()

func (*PlayerResponse) String

func (x *PlayerResponse) String() string

type ResourceType

type ResourceType int
const (
	ResourceType_PLAYER ResourceType = iota
	ResourceType_CHARACTER
	ResourceType_FUNDING_REQUEST
)

type RpgRequest

type RpgRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*RpgRequest) Descriptor deprecated

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

Deprecated: Use RpgRequest.ProtoReflect.Descriptor instead.

func (*RpgRequest) GetId

func (x *RpgRequest) GetId() string

func (*RpgRequest) ProtoMessage

func (*RpgRequest) ProtoMessage()

func (*RpgRequest) ProtoReflect

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

func (*RpgRequest) Reset

func (x *RpgRequest) Reset()

func (*RpgRequest) String

func (x *RpgRequest) String() string

type RpgResponse

type RpgResponse struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*RpgResponse) Descriptor deprecated

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

Deprecated: Use RpgResponse.ProtoReflect.Descriptor instead.

func (*RpgResponse) GetId

func (x *RpgResponse) GetId() string

func (*RpgResponse) ProtoMessage

func (*RpgResponse) ProtoMessage()

func (*RpgResponse) ProtoReflect

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

func (*RpgResponse) Reset

func (x *RpgResponse) Reset()

func (*RpgResponse) String

func (x *RpgResponse) String() string

type RpgServiceClient

type RpgServiceClient interface {
	ReadPlayer(ctx context.Context, in *RpgRequest, opts ...grpc.CallOption) (*PlayerResponse, error)
	CreatePlayer(ctx context.Context, in *pb.Player, opts ...grpc.CallOption) (*pb.Player, error)
	UpdatePlayer(ctx context.Context, in *pb.Player, opts ...grpc.CallOption) (*pb.Player, error)
	DeletePlayer(ctx context.Context, in *RpgRequest, opts ...grpc.CallOption) (*pb.Player, error)
	ReadCharacter(ctx context.Context, in *RpgRequest, opts ...grpc.CallOption) (*CharacterResponse, error)
	CreateCharacter(ctx context.Context, in *pb.Character, opts ...grpc.CallOption) (*pb.Character, error)
	UpdateCharacter(ctx context.Context, in *pb.Character, opts ...grpc.CallOption) (*pb.Character, error)
	DeleteCharacter(ctx context.Context, in *RpgRequest, opts ...grpc.CallOption) (*pb.Character, error)
	FundCharacter(ctx context.Context, in *pb.FundingRequest, opts ...grpc.CallOption) (*pb.Character, error)
	ConductTrade(ctx context.Context, in *pb.TradeRequest, opts ...grpc.CallOption) (*rkcypb.Void, error)
}

RpgServiceClient is the client API for RpgService 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 NewRpgServiceClient

func NewRpgServiceClient(cc grpc.ClientConnInterface) RpgServiceClient

type RpgServiceServer

type RpgServiceServer interface {
	ReadPlayer(context.Context, *RpgRequest) (*PlayerResponse, error)
	CreatePlayer(context.Context, *pb.Player) (*pb.Player, error)
	UpdatePlayer(context.Context, *pb.Player) (*pb.Player, error)
	DeletePlayer(context.Context, *RpgRequest) (*pb.Player, error)
	ReadCharacter(context.Context, *RpgRequest) (*CharacterResponse, error)
	CreateCharacter(context.Context, *pb.Character) (*pb.Character, error)
	UpdateCharacter(context.Context, *pb.Character) (*pb.Character, error)
	DeleteCharacter(context.Context, *RpgRequest) (*pb.Character, error)
	FundCharacter(context.Context, *pb.FundingRequest) (*pb.Character, error)
	ConductTrade(context.Context, *pb.TradeRequest) (*rkcypb.Void, error)
	// contains filtered or unexported methods
}

RpgServiceServer is the server API for RpgService service. All implementations must embed UnimplementedRpgServiceServer for forward compatibility

type Settings

type Settings struct {
	HttpAddr     string
	GrpcAddr     string
	EdgeHttpAddr string

	TimeoutSecs int
}

Cobra sets these values based on command parsing

type UnimplementedRpgServiceServer

type UnimplementedRpgServiceServer struct {
}

UnimplementedRpgServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedRpgServiceServer) ConductTrade

func (UnimplementedRpgServiceServer) CreateCharacter

func (UnimplementedRpgServiceServer) CreatePlayer

func (UnimplementedRpgServiceServer) DeleteCharacter

func (UnimplementedRpgServiceServer) DeletePlayer

func (UnimplementedRpgServiceServer) FundCharacter

func (UnimplementedRpgServiceServer) ReadCharacter

func (UnimplementedRpgServiceServer) ReadPlayer

func (UnimplementedRpgServiceServer) UpdateCharacter

func (UnimplementedRpgServiceServer) UpdatePlayer

type UnsafeRpgServiceServer

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

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

Jump to

Keyboard shortcuts

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