grpcproto

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 8 Imported by: 0

README

` 生成grpc.pb.go 文件

1. mv grpc.proto ..
2. cd ../
3. protoc --go_out=plugins=grpc:. grpc.proto

`

Documentation

Index

Constants

This section is empty.

Variables

Functions

func RegisterGRPCServer

func RegisterGRPCServer(s *grpc.Server, srv GRPCServer)

Types

type GRPCClient

type GRPCClient interface {
	Process(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
}

GRPCClient is the client API for GRPC service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewGRPCClient

func NewGRPCClient(cc grpc.ClientConnInterface) GRPCClient

type GRPCServer

type GRPCServer interface {
	Process(context.Context, *Request) (*Response, error)
}

GRPCServer is the server API for GRPC service.

type Request

type Request struct {
	Service string            `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` //服务名称
	Method  string            `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`   //请求方法,GET
	Header  map[string]string ``                                                                    //请求头信息map[string]string
	/* 153-byte string literal not displayed */
	Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` //请求参数 json
	// contains filtered or unexported fields
}

func (*Request) Descriptor deprecated

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

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetBody

func (x *Request) GetBody() []byte

func (*Request) GetHeader

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

func (*Request) GetMethod

func (x *Request) GetMethod() string

func (*Request) GetService

func (x *Request) GetService() 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

type Response

type Response struct {
	Status int32             `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` //状态码
	Header map[string]string ``                                                                   //返回头信息,map[string]string
	/* 153-byte string literal not displayed */
	Result []byte `protobuf:"bytes,3,opt,name=result,proto3" json:"result,omitempty"` //返回结果,default=json,according to content-type
	// contains filtered or unexported fields
}

func (*Response) Descriptor deprecated

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

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetHeader

func (x *Response) GetHeader() map[string]string

func (*Response) GetResult

func (x *Response) GetResult() []byte

func (*Response) GetStatus

func (x *Response) GetStatus() int32

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

type UnimplementedGRPCServer

type UnimplementedGRPCServer struct {
}

UnimplementedGRPCServer can be embedded to have forward compatible implementations.

func (*UnimplementedGRPCServer) Process

Jump to

Keyboard shortcuts

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