pb

package
v0.0.0-...-6ac53a6 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package pb is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_server_proto protoreflect.FileDescriptor

Functions

func RegisterServerHandler

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

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

func RegisterServerHandlerClient

func RegisterServerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServerClient) error

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

func RegisterServerHandlerFromEndpoint

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

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

func RegisterServerHandlerServer

func RegisterServerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServerServer) error

RegisterServerHandlerServer registers the http handlers for service Server to "mux". UnaryRPC :call ServerServer 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 RegisterServerHandlerFromEndpoint instead.

func RegisterServerServer

func RegisterServerServer(s *grpc.Server, srv ServerServer)

Types

type Request

type Request struct {
	Type    string            `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Message string            `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Meta    map[string]string `` /* 149-byte string literal not displayed */
	Code    int32             `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"`
	// contains filtered or unexported fields
}

The parameters to Server.Info.

func (*Request) Descriptor deprecated

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

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetCode

func (x *Request) GetCode() int32

func (*Request) GetMessage

func (x *Request) GetMessage() string

func (*Request) GetMeta

func (x *Request) GetMeta() map[string]string

func (*Request) GetType

func (x *Request) GetType() string

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) ProtoReflect

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

func (*Request) Reset

func (x *Request) Reset()

func (*Request) String

func (x *Request) String() string

func (*Request) Validate

func (m *Request) Validate() error

Validate checks the field values on Request with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

type RequestValidationError

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

RequestValidationError is the validation error returned by Request.Validate if the designated constraints aren't met.

func (RequestValidationError) Cause

func (e RequestValidationError) Cause() error

Cause function returns cause value.

func (RequestValidationError) Error

func (e RequestValidationError) Error() string

Error satisfies the builtin error interface

func (RequestValidationError) ErrorName

func (e RequestValidationError) ErrorName() string

ErrorName returns error name.

func (RequestValidationError) Field

func (e RequestValidationError) Field() string

Field function returns field value.

func (RequestValidationError) Key

func (e RequestValidationError) Key() bool

Key function returns key value.

func (RequestValidationError) Reason

func (e RequestValidationError) Reason() string

Reason function returns reason value.

type Response

type Response struct {
	Request *Request                  `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"`
	Data    map[string]*Response_List `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

The Response to Server.Info.

func (*Response) Descriptor deprecated

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

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetData

func (x *Response) GetData() map[string]*Response_List

func (*Response) GetRequest

func (x *Response) GetRequest() *Request

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

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

func (*Response) Reset

func (x *Response) Reset()

func (*Response) String

func (x *Response) String() string

func (*Response) Validate

func (m *Response) Validate() error

Validate checks the field values on Response with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

type ResponseValidationError

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

ResponseValidationError is the validation error returned by Response.Validate if the designated constraints aren't met.

func (ResponseValidationError) Cause

func (e ResponseValidationError) Cause() error

Cause function returns cause value.

func (ResponseValidationError) Error

func (e ResponseValidationError) Error() string

Error satisfies the builtin error interface

func (ResponseValidationError) ErrorName

func (e ResponseValidationError) ErrorName() string

ErrorName returns error name.

func (ResponseValidationError) Field

func (e ResponseValidationError) Field() string

Field function returns field value.

func (ResponseValidationError) Key

func (e ResponseValidationError) Key() bool

Key function returns key value.

func (ResponseValidationError) Reason

func (e ResponseValidationError) Reason() string

Reason function returns reason value.

type Response_List

type Response_List struct {
	List []string `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
	// contains filtered or unexported fields
}

func (*Response_List) Descriptor deprecated

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

Deprecated: Use Response_List.ProtoReflect.Descriptor instead.

func (*Response_List) GetList

func (x *Response_List) GetList() []string

func (*Response_List) ProtoMessage

func (*Response_List) ProtoMessage()

func (*Response_List) ProtoReflect

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

func (*Response_List) Reset

func (x *Response_List) Reset()

func (*Response_List) String

func (x *Response_List) String() string

func (*Response_List) Validate

func (m *Response_List) Validate() error

Validate checks the field values on Response_List with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

type Response_ListValidationError

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

Response_ListValidationError is the validation error returned by Response_List.Validate if the designated constraints aren't met.

func (Response_ListValidationError) Cause

Cause function returns cause value.

func (Response_ListValidationError) Error

Error satisfies the builtin error interface

func (Response_ListValidationError) ErrorName

func (e Response_ListValidationError) ErrorName() string

ErrorName returns error name.

func (Response_ListValidationError) Field

Field function returns field value.

func (Response_ListValidationError) Key

Key function returns key value.

func (Response_ListValidationError) Reason

Reason function returns reason value.

type ServerClient

type ServerClient interface {
	// Get grpc request infos
	Info(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
	// Post
	Post(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
}

ServerClient is the client API for Server 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 NewServerClient

func NewServerClient(cc grpc.ClientConnInterface) ServerClient

type ServerServer

type ServerServer interface {
	// Get grpc request infos
	Info(context.Context, *Request) (*Response, error)
	// Post
	Post(context.Context, *Request) (*Response, error)
	// contains filtered or unexported methods
}

ServerServer is the server API for Server service. All implementations must embed UnimplementedServerServer for forward compatibility

type UnimplementedServerServer

type UnimplementedServerServer struct {
}

UnimplementedServerServer must be embedded to have forward compatible implementations.

func (UnimplementedServerServer) Info

func (UnimplementedServerServer) Post

type UnsafeServerServer

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

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

Jump to

Keyboard shortcuts

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