proto

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package proto is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	Echo_Ping_FullMethodName = "/echo.Echo/Ping"
)

Variables

View Source
var Echo_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "echo.Echo",
	HandlerType: (*EchoServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Ping",
			Handler:    _Echo_Ping_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "echo.proto",
}

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

Functions

func RegisterEchoHandler added in v0.3.0

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

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

func RegisterEchoHandlerClient added in v0.3.0

func RegisterEchoHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EchoClient) error

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

func RegisterEchoHandlerFromEndpoint added in v0.3.0

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

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

func RegisterEchoHandlerServer added in v0.3.0

func RegisterEchoHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EchoServer) error

RegisterEchoHandlerServer registers the http handlers for service Echo to "mux". UnaryRPC :call EchoServer 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 RegisterEchoHandlerFromEndpoint instead.

func RegisterEchoServer

func RegisterEchoServer(s grpc.ServiceRegistrar, srv EchoServer)

Types

type EchoClient

type EchoClient interface {
	Ping(ctx context.Context, in *PingMessage, opts ...grpc.CallOption) (*PongMessage, error)
}

EchoClient is the client API for Echo 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 NewEchoClient

func NewEchoClient(cc grpc.ClientConnInterface) EchoClient

type EchoServer

type EchoServer interface {
	Ping(context.Context, *PingMessage) (*PongMessage, error)
	// contains filtered or unexported methods
}

EchoServer is the server API for Echo service. All implementations must embed UnimplementedEchoServer for forward compatibility

type PingMessage

type PingMessage struct {
	DelaySeconds float64 `protobuf:"fixed64,1,opt,name=delaySeconds,proto3" json:"delaySeconds,omitempty"`
	Payload      string  `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*PingMessage) Descriptor deprecated

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

Deprecated: Use PingMessage.ProtoReflect.Descriptor instead.

func (*PingMessage) GetDelaySeconds

func (x *PingMessage) GetDelaySeconds() float64

func (*PingMessage) GetPayload

func (x *PingMessage) GetPayload() string

func (*PingMessage) ProtoMessage

func (*PingMessage) ProtoMessage()

func (*PingMessage) ProtoReflect

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

func (*PingMessage) Reset

func (x *PingMessage) Reset()

func (*PingMessage) String

func (x *PingMessage) String() string

type PongMessage

type PongMessage struct {
	Timestamp  string `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Hostname   string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"`
	Version    string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
	RemoteIp   string `protobuf:"bytes,4,opt,name=remoteIp,proto3" json:"remoteIp,omitempty"`
	RemotePort int32  `protobuf:"varint,5,opt,name=remotePort,proto3" json:"remotePort,omitempty"`
	// reserve a field for real client ip
	// string clientIp = 6;
	RequestId     string  `protobuf:"bytes,7,opt,name=requestId,proto3" json:"requestId,omitempty"`
	Authority     string  `protobuf:"bytes,8,opt,name=authority,proto3" json:"authority,omitempty"`
	RequestMethod string  `protobuf:"bytes,9,opt,name=requestMethod,proto3" json:"requestMethod,omitempty"`
	RequestTime   float64 `protobuf:"fixed64,10,opt,name=requestTime,proto3" json:"requestTime,omitempty"`
	UserAgent     string  `protobuf:"bytes,11,opt,name=userAgent,proto3" json:"userAgent,omitempty"`
	DelaySeconds  float64 `protobuf:"fixed64,21,opt,name=delaySeconds,proto3" json:"delaySeconds,omitempty"`
	Payload       string  `protobuf:"bytes,22,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*PongMessage) Descriptor deprecated

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

Deprecated: Use PongMessage.ProtoReflect.Descriptor instead.

func (*PongMessage) GetAuthority

func (x *PongMessage) GetAuthority() string

func (*PongMessage) GetDelaySeconds

func (x *PongMessage) GetDelaySeconds() float64

func (*PongMessage) GetHostname

func (x *PongMessage) GetHostname() string

func (*PongMessage) GetPayload

func (x *PongMessage) GetPayload() string

func (*PongMessage) GetRemoteIp

func (x *PongMessage) GetRemoteIp() string

func (*PongMessage) GetRemotePort

func (x *PongMessage) GetRemotePort() int32

func (*PongMessage) GetRequestId

func (x *PongMessage) GetRequestId() string

func (*PongMessage) GetRequestMethod

func (x *PongMessage) GetRequestMethod() string

func (*PongMessage) GetRequestTime

func (x *PongMessage) GetRequestTime() float64

func (*PongMessage) GetTimestamp

func (x *PongMessage) GetTimestamp() string

func (*PongMessage) GetUserAgent

func (x *PongMessage) GetUserAgent() string

func (*PongMessage) GetVersion

func (x *PongMessage) GetVersion() string

func (*PongMessage) ProtoMessage

func (*PongMessage) ProtoMessage()

func (*PongMessage) ProtoReflect

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

func (*PongMessage) Reset

func (x *PongMessage) Reset()

func (*PongMessage) String

func (x *PongMessage) String() string

type UnimplementedEchoServer

type UnimplementedEchoServer struct {
}

UnimplementedEchoServer must be embedded to have forward compatible implementations.

func (UnimplementedEchoServer) Ping

type UnsafeEchoServer

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

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

Jump to

Keyboard shortcuts

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