pb

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

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

Go to latest
Published: May 29, 2023 License: BSD-3-Clause 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 (
	ErrorCode_name = map[int32]string{
		0:    "OK",
		4404: "CustomNotFound",
	}
	ErrorCode_value = map[string]int32{
		"OK":             0,
		"CustomNotFound": 4404,
	}
)

Enum value maps for ErrorCode.

View Source
var File_api_proto_error_proto protoreflect.FileDescriptor
View Source
var File_api_proto_main_proto protoreflect.FileDescriptor
View Source
var Say_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "pb.Say",
	HandlerType: (*SayServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Hello",
			Handler:    _Say_Hello_Handler,
		},
		{
			MethodName: "Topic",
			Handler:    _Say_Topic_Handler,
		},
		{
			MethodName: "RpcCli",
			Handler:    _Say_RpcCli_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "api/proto/main.proto",
}

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

Functions

func RegisterSayHandler

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

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

func RegisterSayHandlerClient

func RegisterSayHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SayClient) error

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

func RegisterSayHandlerFromEndpoint

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

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

func RegisterSayHandlerServer

func RegisterSayHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SayServer) error

RegisterSayHandlerServer registers the http handlers for service Say to "mux". UnaryRPC :call SayServer 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 RegisterSayHandlerFromEndpoint instead.

func RegisterSayServer

func RegisterSayServer(s grpc.ServiceRegistrar, srv SayServer)

Types

type ErrorCode

type ErrorCode int32

ErrorCode 错误码枚举类型 一般错误,参考: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto

const (
	ErrorCode_OK ErrorCode = 0
	// 任务不存在, server 框架 会自动给用户输出 ResourceNotFound.TaskNotFound
	// 的错误码。
	ErrorCode_CustomNotFound ErrorCode = 4404
)

func (ErrorCode) Descriptor

func (ErrorCode) Descriptor() protoreflect.EnumDescriptor

func (ErrorCode) Enum

func (x ErrorCode) Enum() *ErrorCode

func (ErrorCode) EnumDescriptor deprecated

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

Deprecated: Use ErrorCode.Descriptor instead.

func (ErrorCode) Number

func (x ErrorCode) Number() protoreflect.EnumNumber

func (ErrorCode) String

func (x ErrorCode) String() string

func (ErrorCode) Type

type HelloReq

type HelloReq struct {

	// 姓名
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

Hello 请求

func (*HelloReq) Descriptor deprecated

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

Deprecated: Use HelloReq.ProtoReflect.Descriptor instead.

func (*HelloReq) GetName

func (x *HelloReq) GetName() string

func (*HelloReq) ProtoMessage

func (*HelloReq) ProtoMessage()

func (*HelloReq) ProtoReflect

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

func (*HelloReq) Reset

func (x *HelloReq) Reset()

func (*HelloReq) String

func (x *HelloReq) String() string

func (*HelloReq) Validate

func (m *HelloReq) Validate() error

Validate checks the field values on HelloReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*HelloReq) ValidateAll

func (m *HelloReq) ValidateAll() error

ValidateAll checks the field values on HelloReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HelloReqMultiError, or nil if none found.

type HelloReqMultiError

type HelloReqMultiError []error

HelloReqMultiError is an error wrapping multiple validation errors returned by HelloReq.ValidateAll() if the designated constraints aren't met.

func (HelloReqMultiError) AllErrors

func (m HelloReqMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (HelloReqMultiError) Error

func (m HelloReqMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type HelloReqValidationError

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

HelloReqValidationError is the validation error returned by HelloReq.Validate if the designated constraints aren't met.

func (HelloReqValidationError) Cause

func (e HelloReqValidationError) Cause() error

Cause function returns cause value.

func (HelloReqValidationError) Error

func (e HelloReqValidationError) Error() string

Error satisfies the builtin error interface

func (HelloReqValidationError) ErrorName

func (e HelloReqValidationError) ErrorName() string

ErrorName returns error name.

func (HelloReqValidationError) Field

func (e HelloReqValidationError) Field() string

Field function returns field value.

func (HelloReqValidationError) Key

func (e HelloReqValidationError) Key() bool

Key function returns key value.

func (HelloReqValidationError) Reason

func (e HelloReqValidationError) Reason() string

Reason function returns reason value.

type HelloRes

type HelloRes struct {

	// 回复消息
	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
	// contains filtered or unexported fields
}

Hello 响应

func (*HelloRes) Descriptor deprecated

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

Deprecated: Use HelloRes.ProtoReflect.Descriptor instead.

func (*HelloRes) GetMsg

func (x *HelloRes) GetMsg() string

func (*HelloRes) ProtoMessage

func (*HelloRes) ProtoMessage()

func (*HelloRes) ProtoReflect

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

func (*HelloRes) Reset

func (x *HelloRes) Reset()

func (*HelloRes) String

func (x *HelloRes) String() string

func (*HelloRes) Validate

func (m *HelloRes) Validate() error

Validate checks the field values on HelloRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*HelloRes) ValidateAll

func (m *HelloRes) ValidateAll() error

ValidateAll checks the field values on HelloRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HelloResMultiError, or nil if none found.

type HelloResMultiError

type HelloResMultiError []error

HelloResMultiError is an error wrapping multiple validation errors returned by HelloRes.ValidateAll() if the designated constraints aren't met.

func (HelloResMultiError) AllErrors

func (m HelloResMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (HelloResMultiError) Error

func (m HelloResMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type HelloResValidationError

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

HelloResValidationError is the validation error returned by HelloRes.Validate if the designated constraints aren't met.

func (HelloResValidationError) Cause

func (e HelloResValidationError) Cause() error

Cause function returns cause value.

func (HelloResValidationError) Error

func (e HelloResValidationError) Error() string

Error satisfies the builtin error interface

func (HelloResValidationError) ErrorName

func (e HelloResValidationError) ErrorName() string

ErrorName returns error name.

func (HelloResValidationError) Field

func (e HelloResValidationError) Field() string

Field function returns field value.

func (HelloResValidationError) Key

func (e HelloResValidationError) Key() bool

Key function returns key value.

func (HelloResValidationError) Reason

func (e HelloResValidationError) Reason() string

Reason function returns reason value.

type RpcCliReq

type RpcCliReq struct {

	// 姓名
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*RpcCliReq) Descriptor deprecated

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

Deprecated: Use RpcCliReq.ProtoReflect.Descriptor instead.

func (*RpcCliReq) GetName

func (x *RpcCliReq) GetName() string

func (*RpcCliReq) ProtoMessage

func (*RpcCliReq) ProtoMessage()

func (*RpcCliReq) ProtoReflect

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

func (*RpcCliReq) Reset

func (x *RpcCliReq) Reset()

func (*RpcCliReq) String

func (x *RpcCliReq) String() string

func (*RpcCliReq) Validate

func (m *RpcCliReq) Validate() error

Validate checks the field values on RpcCliReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*RpcCliReq) ValidateAll

func (m *RpcCliReq) ValidateAll() error

ValidateAll checks the field values on RpcCliReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in RpcCliReqMultiError, or nil if none found.

type RpcCliReqMultiError

type RpcCliReqMultiError []error

RpcCliReqMultiError is an error wrapping multiple validation errors returned by RpcCliReq.ValidateAll() if the designated constraints aren't met.

func (RpcCliReqMultiError) AllErrors

func (m RpcCliReqMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (RpcCliReqMultiError) Error

func (m RpcCliReqMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type RpcCliReqValidationError

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

RpcCliReqValidationError is the validation error returned by RpcCliReq.Validate if the designated constraints aren't met.

func (RpcCliReqValidationError) Cause

func (e RpcCliReqValidationError) Cause() error

Cause function returns cause value.

func (RpcCliReqValidationError) Error

func (e RpcCliReqValidationError) Error() string

Error satisfies the builtin error interface

func (RpcCliReqValidationError) ErrorName

func (e RpcCliReqValidationError) ErrorName() string

ErrorName returns error name.

func (RpcCliReqValidationError) Field

func (e RpcCliReqValidationError) Field() string

Field function returns field value.

func (RpcCliReqValidationError) Key

Key function returns key value.

func (RpcCliReqValidationError) Reason

func (e RpcCliReqValidationError) Reason() string

Reason function returns reason value.

type RpcCliRes

type RpcCliRes struct {

	// 回复消息
	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
	// contains filtered or unexported fields
}

func (*RpcCliRes) Descriptor deprecated

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

Deprecated: Use RpcCliRes.ProtoReflect.Descriptor instead.

func (*RpcCliRes) GetMsg

func (x *RpcCliRes) GetMsg() string

func (*RpcCliRes) ProtoMessage

func (*RpcCliRes) ProtoMessage()

func (*RpcCliRes) ProtoReflect

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

func (*RpcCliRes) Reset

func (x *RpcCliRes) Reset()

func (*RpcCliRes) String

func (x *RpcCliRes) String() string

func (*RpcCliRes) Validate

func (m *RpcCliRes) Validate() error

Validate checks the field values on RpcCliRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*RpcCliRes) ValidateAll

func (m *RpcCliRes) ValidateAll() error

ValidateAll checks the field values on RpcCliRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in RpcCliResMultiError, or nil if none found.

type RpcCliResMultiError

type RpcCliResMultiError []error

RpcCliResMultiError is an error wrapping multiple validation errors returned by RpcCliRes.ValidateAll() if the designated constraints aren't met.

func (RpcCliResMultiError) AllErrors

func (m RpcCliResMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (RpcCliResMultiError) Error

func (m RpcCliResMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type RpcCliResValidationError

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

RpcCliResValidationError is the validation error returned by RpcCliRes.Validate if the designated constraints aren't met.

func (RpcCliResValidationError) Cause

func (e RpcCliResValidationError) Cause() error

Cause function returns cause value.

func (RpcCliResValidationError) Error

func (e RpcCliResValidationError) Error() string

Error satisfies the builtin error interface

func (RpcCliResValidationError) ErrorName

func (e RpcCliResValidationError) ErrorName() string

ErrorName returns error name.

func (RpcCliResValidationError) Field

func (e RpcCliResValidationError) Field() string

Field function returns field value.

func (RpcCliResValidationError) Key

Key function returns key value.

func (RpcCliResValidationError) Reason

func (e RpcCliResValidationError) Reason() string

Reason function returns reason value.

type SayClient

type SayClient interface {
	// 测试HelloWorld
	Hello(ctx context.Context, in *HelloReq, opts ...grpc.CallOption) (*HelloRes, error)
	Topic(ctx context.Context, in *TopicReq, opts ...grpc.CallOption) (*TopicRes, error)
	RpcCli(ctx context.Context, in *RpcCliReq, opts ...grpc.CallOption) (*RpcCliRes, error)
}

SayClient is the client API for Say 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 NewSayClient

func NewSayClient(cc grpc.ClientConnInterface) SayClient

type SayServer

type SayServer interface {
	// 测试HelloWorld
	Hello(context.Context, *HelloReq) (*HelloRes, error)
	Topic(context.Context, *TopicReq) (*TopicRes, error)
	RpcCli(context.Context, *RpcCliReq) (*RpcCliRes, error)
	// contains filtered or unexported methods
}

SayServer is the server API for Say service. All implementations must embed UnimplementedSayServer for forward compatibility

type TopicReq

type TopicReq struct {

	// 姓名
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*TopicReq) Descriptor deprecated

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

Deprecated: Use TopicReq.ProtoReflect.Descriptor instead.

func (*TopicReq) GetName

func (x *TopicReq) GetName() string

func (*TopicReq) ProtoMessage

func (*TopicReq) ProtoMessage()

func (*TopicReq) ProtoReflect

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

func (*TopicReq) Reset

func (x *TopicReq) Reset()

func (*TopicReq) String

func (x *TopicReq) String() string

func (*TopicReq) Validate

func (m *TopicReq) Validate() error

Validate checks the field values on TopicReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*TopicReq) ValidateAll

func (m *TopicReq) ValidateAll() error

ValidateAll checks the field values on TopicReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in TopicReqMultiError, or nil if none found.

type TopicReqMultiError

type TopicReqMultiError []error

TopicReqMultiError is an error wrapping multiple validation errors returned by TopicReq.ValidateAll() if the designated constraints aren't met.

func (TopicReqMultiError) AllErrors

func (m TopicReqMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (TopicReqMultiError) Error

func (m TopicReqMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type TopicReqValidationError

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

TopicReqValidationError is the validation error returned by TopicReq.Validate if the designated constraints aren't met.

func (TopicReqValidationError) Cause

func (e TopicReqValidationError) Cause() error

Cause function returns cause value.

func (TopicReqValidationError) Error

func (e TopicReqValidationError) Error() string

Error satisfies the builtin error interface

func (TopicReqValidationError) ErrorName

func (e TopicReqValidationError) ErrorName() string

ErrorName returns error name.

func (TopicReqValidationError) Field

func (e TopicReqValidationError) Field() string

Field function returns field value.

func (TopicReqValidationError) Key

func (e TopicReqValidationError) Key() bool

Key function returns key value.

func (TopicReqValidationError) Reason

func (e TopicReqValidationError) Reason() string

Reason function returns reason value.

type TopicRes

type TopicRes struct {

	// 回复消息
	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
	// contains filtered or unexported fields
}

func (*TopicRes) Descriptor deprecated

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

Deprecated: Use TopicRes.ProtoReflect.Descriptor instead.

func (*TopicRes) GetMsg

func (x *TopicRes) GetMsg() string

func (*TopicRes) ProtoMessage

func (*TopicRes) ProtoMessage()

func (*TopicRes) ProtoReflect

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

func (*TopicRes) Reset

func (x *TopicRes) Reset()

func (*TopicRes) String

func (x *TopicRes) String() string

func (*TopicRes) Validate

func (m *TopicRes) Validate() error

Validate checks the field values on TopicRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*TopicRes) ValidateAll

func (m *TopicRes) ValidateAll() error

ValidateAll checks the field values on TopicRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in TopicResMultiError, or nil if none found.

type TopicResMultiError

type TopicResMultiError []error

TopicResMultiError is an error wrapping multiple validation errors returned by TopicRes.ValidateAll() if the designated constraints aren't met.

func (TopicResMultiError) AllErrors

func (m TopicResMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (TopicResMultiError) Error

func (m TopicResMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type TopicResValidationError

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

TopicResValidationError is the validation error returned by TopicRes.Validate if the designated constraints aren't met.

func (TopicResValidationError) Cause

func (e TopicResValidationError) Cause() error

Cause function returns cause value.

func (TopicResValidationError) Error

func (e TopicResValidationError) Error() string

Error satisfies the builtin error interface

func (TopicResValidationError) ErrorName

func (e TopicResValidationError) ErrorName() string

ErrorName returns error name.

func (TopicResValidationError) Field

func (e TopicResValidationError) Field() string

Field function returns field value.

func (TopicResValidationError) Key

func (e TopicResValidationError) Key() bool

Key function returns key value.

func (TopicResValidationError) Reason

func (e TopicResValidationError) Reason() string

Reason function returns reason value.

type UnimplementedSayServer

type UnimplementedSayServer struct {
}

UnimplementedSayServer must be embedded to have forward compatible implementations.

func (UnimplementedSayServer) Hello

func (UnimplementedSayServer) RpcCli

func (UnimplementedSayServer) Topic

type UnsafeSayServer

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

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

Jump to

Keyboard shortcuts

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