protobuf

package module
v0.0.0-...-6d10e06 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GreetService_Hello_FullMethodName       = "/proto.GreetService/Hello"
	GreetService_HelloStream_FullMethodName = "/proto.GreetService/HelloStream"
)

Variables

View Source
var (
	Type_name = map[int32]string{
		0: "NORMAL",
		1: "PING",
		2: "PONG",
	}
	Type_value = map[string]int32{
		"NORMAL": 0,
		"PING":   1,
		"PONG":   2,
	}
)

Enum value maps for Type.

View Source
var (
	Response_Status_name = map[int32]string{
		0: "OK",
		1: "ERROR",
	}
	Response_Status_value = map[string]int32{
		"OK":    0,
		"ERROR": 1,
	}
)

Enum value maps for Response_Status.

View Source
var File_pkg_protobuf_message_proto protoreflect.FileDescriptor
View Source
var GreetService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "proto.GreetService",
	HandlerType: (*GreetServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Hello",
			Handler:    _GreetService_Hello_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "HelloStream",
			Handler:       _GreetService_HelloStream_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "pkg/protobuf/message.proto",
}

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

Functions

func RegisterGreetServiceServer

func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer)

Types

type GreetServiceClient

type GreetServiceClient interface {
	// Unary RPC
	// 客户端发起了一个RPC请求到服务端,服务端进行业务处理并返回响应给客户端,
	// 这是gRPC最基本的一种工作方式(Unary RPC)
	Hello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
	// Streaming RPC
	// 服务端流,客户端发出一个RPC请求,服务端客户端与之间建立一个单向的流。
	// 服务端可以向流中写入多个响应消息,最后主动关闭流;而客户端需要监听这个流,不断获取响应直到流关闭。
	// 应用场景举例:客户端向服务端发送一个股票代码,服务端就把该股票的实时数据源源不断的返回给客户端。
	//
	// 客户端流,客户端传入多个请求对象,服务端返回一个响应结果。
	// 典型的应用场景举例:物联网终端向服务器上报数据、大数据流式计算等。
	//
	// 双向流,双向流式RPC即客户端和服务端均为流式的RPC,能发送多个请求对象也能接收到多个响应对象。
	// 典型应用示例:聊天应用等。
	HelloStream(ctx context.Context, opts ...grpc.CallOption) (GreetService_HelloStreamClient, error)
}

GreetServiceClient is the client API for GreetService 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.

type GreetServiceServer

type GreetServiceServer interface {
	// Unary RPC
	// 客户端发起了一个RPC请求到服务端,服务端进行业务处理并返回响应给客户端,
	// 这是gRPC最基本的一种工作方式(Unary RPC)
	Hello(context.Context, *Request) (*Response, error)
	// Streaming RPC
	// 服务端流,客户端发出一个RPC请求,服务端客户端与之间建立一个单向的流。
	// 服务端可以向流中写入多个响应消息,最后主动关闭流;而客户端需要监听这个流,不断获取响应直到流关闭。
	// 应用场景举例:客户端向服务端发送一个股票代码,服务端就把该股票的实时数据源源不断的返回给客户端。
	//
	// 客户端流,客户端传入多个请求对象,服务端返回一个响应结果。
	// 典型的应用场景举例:物联网终端向服务器上报数据、大数据流式计算等。
	//
	// 双向流,双向流式RPC即客户端和服务端均为流式的RPC,能发送多个请求对象也能接收到多个响应对象。
	// 典型应用示例:聊天应用等。
	HelloStream(GreetService_HelloStreamServer) error
	// contains filtered or unexported methods
}

GreetServiceServer is the server API for GreetService service. All implementations must embed UnimplementedGreetServiceServer for forward compatibility

func NewGreetServiceServer

func NewGreetServiceServer() GreetServiceServer

type GreetService_HelloStreamClient

type GreetService_HelloStreamClient interface {
	Send(*Request) error
	Recv() (*Response, error)
	grpc.ClientStream
}

type GreetService_HelloStreamServer

type GreetService_HelloStreamServer interface {
	Send(*Response) error
	Recv() (*Request, error)
	grpc.ServerStream
}

type Request

type Request struct {
	Id   int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Type Type   `protobuf:"varint,2,opt,name=type,proto3,enum=proto.Type" json:"type,omitempty"`
	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Request) Descriptor deprecated

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

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetData

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

func (*Request) GetId

func (x *Request) GetId() int64

func (*Request) GetType

func (x *Request) GetType() Type

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 {
	Id     int64           `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Type   Type            `protobuf:"varint,2,opt,name=type,proto3,enum=proto.Type" json:"type,omitempty"`
	Status Response_Status `protobuf:"varint,3,opt,name=status,proto3,enum=proto.Response_Status" json:"status,omitempty"`
	Data   []byte          `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Response) Descriptor deprecated

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

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetData

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

func (*Response) GetId

func (x *Response) GetId() int64

func (*Response) GetStatus

func (x *Response) GetStatus() Response_Status

func (*Response) GetType

func (x *Response) GetType() Type

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 Response_Status

type Response_Status int32
const (
	Response_OK    Response_Status = 0
	Response_ERROR Response_Status = 1
)

func (Response_Status) Descriptor

func (Response_Status) Enum

func (x Response_Status) Enum() *Response_Status

func (Response_Status) EnumDescriptor deprecated

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

Deprecated: Use Response_Status.Descriptor instead.

func (Response_Status) Number

func (Response_Status) String

func (x Response_Status) String() string

func (Response_Status) Type

type Type

type Type int32
const (
	Type_NORMAL Type = 0
	Type_PING   Type = 1
	Type_PONG   Type = 2
)

func (Type) Descriptor

func (Type) Descriptor() protoreflect.EnumDescriptor

func (Type) Enum

func (x Type) Enum() *Type

func (Type) EnumDescriptor deprecated

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

Deprecated: Use Type.Descriptor instead.

func (Type) Number

func (x Type) Number() protoreflect.EnumNumber

func (Type) String

func (x Type) String() string

func (Type) Type

func (Type) Type() protoreflect.EnumType

type UnimplementedGreetServiceServer

type UnimplementedGreetServiceServer struct {
}

UnimplementedGreetServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedGreetServiceServer) Hello

func (UnimplementedGreetServiceServer) HelloStream

type UnsafeGreetServiceServer

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

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

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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