pb

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Demo_SayHello_FullMethodName  = "/test.Demo/SayHello"
	Demo_CountDown_FullMethodName = "/test.Demo/CountDown"
	Demo_Sum_FullMethodName       = "/test.Demo/Sum"
	Demo_Chat_FullMethodName      = "/test.Demo/Chat"
	Demo_Health_FullMethodName    = "/test.Demo/Health"
)

Variables

View Source
var (
	HealthCheckResponse_Status_name = map[int32]string{
		0: "UNKNOWN",
		1: "SERVING",
		2: "NOT_SERVING",
	}
	HealthCheckResponse_Status_value = map[string]int32{
		"UNKNOWN":     0,
		"SERVING":     1,
		"NOT_SERVING": 2,
	}
)

Enum value maps for HealthCheckResponse_Status.

View Source
var Demo_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "test.Demo",
	HandlerType: (*DemoServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SayHello",
			Handler:    _Demo_SayHello_Handler,
		},
		{
			MethodName: "Health",
			Handler:    _Demo_Health_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "CountDown",
			Handler:       _Demo_CountDown_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "Sum",
			Handler:       _Demo_Sum_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "Chat",
			Handler:       _Demo_Chat_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "test.proto",
}

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

Functions

func RegisterDemoServer

func RegisterDemoServer(s grpc.ServiceRegistrar, srv DemoServer)

Types

type ChatMessage

type ChatMessage struct {
	From   string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`                    // 发送者 ID/昵称
	Text   string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`                    // 文本内容
	Seq    int64  `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"`                     // 自增序号(客户端或服务端维护均可)
	TsUnix int64  `protobuf:"varint,4,opt,name=ts_unix,json=tsUnix,proto3" json:"ts_unix,omitempty"` // 发送时间
	// contains filtered or unexported fields
}

========== Chat(Bidirectional streaming)==========

func (*ChatMessage) Descriptor deprecated

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

Deprecated: Use ChatMessage.ProtoReflect.Descriptor instead.

func (*ChatMessage) GetFrom

func (x *ChatMessage) GetFrom() string

func (*ChatMessage) GetSeq

func (x *ChatMessage) GetSeq() int64

func (*ChatMessage) GetText

func (x *ChatMessage) GetText() string

func (*ChatMessage) GetTsUnix

func (x *ChatMessage) GetTsUnix() int64

func (*ChatMessage) ProtoMessage

func (*ChatMessage) ProtoMessage()

func (*ChatMessage) ProtoReflect

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

func (*ChatMessage) Reset

func (x *ChatMessage) Reset()

func (*ChatMessage) String

func (x *ChatMessage) String() string

type CountDownReply

type CountDownReply struct {
	Current int32 `protobuf:"varint,1,opt,name=current,proto3" json:"current,omitempty"` // 当前数字
	TsUnix  int64 `protobuf:"varint,2,opt,name=ts_unix,json=tsUnix,proto3" json:"ts_unix,omitempty"`
	// contains filtered or unexported fields
}

func (*CountDownReply) Descriptor deprecated

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

Deprecated: Use CountDownReply.ProtoReflect.Descriptor instead.

func (*CountDownReply) GetCurrent

func (x *CountDownReply) GetCurrent() int32

func (*CountDownReply) GetTsUnix

func (x *CountDownReply) GetTsUnix() int64

func (*CountDownReply) ProtoMessage

func (*CountDownReply) ProtoMessage()

func (*CountDownReply) ProtoReflect

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

func (*CountDownReply) Reset

func (x *CountDownReply) Reset()

func (*CountDownReply) String

func (x *CountDownReply) String() string

type CountDownRequest

type CountDownRequest struct {
	From       int32 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"`                               // 例如 from=5 -> 5,4,3,2,1
	IntervalMs int32 `protobuf:"varint,2,opt,name=interval_ms,json=intervalMs,proto3" json:"interval_ms,omitempty"` // 两次下发间隔,默认可由服务端设定
	// contains filtered or unexported fields
}

========== CountDown ==========

func (*CountDownRequest) Descriptor deprecated

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

Deprecated: Use CountDownRequest.ProtoReflect.Descriptor instead.

func (*CountDownRequest) GetFrom

func (x *CountDownRequest) GetFrom() int32

func (*CountDownRequest) GetIntervalMs

func (x *CountDownRequest) GetIntervalMs() int32

func (*CountDownRequest) ProtoMessage

func (*CountDownRequest) ProtoMessage()

func (*CountDownRequest) ProtoReflect

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

func (*CountDownRequest) Reset

func (x *CountDownRequest) Reset()

func (*CountDownRequest) String

func (x *CountDownRequest) String() string

type DemoClient

type DemoClient interface {
	// 1) Unary:最基础的请求-响应
	SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
	// 2) Server streaming:服务端流式把倒计时发回去
	CountDown(ctx context.Context, in *CountDownRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[CountDownReply], error)
	// 3) Client streaming:客户端连续发数字,服务端汇总
	Sum(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[SumRequest, SumReply], error)
	// 4) Bidirectional streaming:简易聊天室
	Chat(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[ChatMessage, ChatMessage], error)
	// 5) 简易健康检查(避免额外引入官方 health proto)
	Health(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
}

DemoClient is the client API for Demo 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 NewDemoClient

func NewDemoClient(cc grpc.ClientConnInterface) DemoClient

type DemoServer

type DemoServer interface {
	// 1) Unary:最基础的请求-响应
	SayHello(context.Context, *HelloRequest) (*HelloReply, error)
	// 2) Server streaming:服务端流式把倒计时发回去
	CountDown(*CountDownRequest, grpc.ServerStreamingServer[CountDownReply]) error
	// 3) Client streaming:客户端连续发数字,服务端汇总
	Sum(grpc.ClientStreamingServer[SumRequest, SumReply]) error
	// 4) Bidirectional streaming:简易聊天室
	Chat(grpc.BidiStreamingServer[ChatMessage, ChatMessage]) error
	// 5) 简易健康检查(避免额外引入官方 health proto)
	Health(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
	// contains filtered or unexported methods
}

DemoServer is the server API for Demo service. All implementations must embed UnimplementedDemoServer for forward compatibility.

type Demo_ChatClient

type Demo_ChatClient = grpc.BidiStreamingClient[ChatMessage, ChatMessage]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Demo_ChatServer

type Demo_ChatServer = grpc.BidiStreamingServer[ChatMessage, ChatMessage]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Demo_CountDownClient

type Demo_CountDownClient = grpc.ServerStreamingClient[CountDownReply]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Demo_CountDownServer

type Demo_CountDownServer = grpc.ServerStreamingServer[CountDownReply]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Demo_SumClient

type Demo_SumClient = grpc.ClientStreamingClient[SumRequest, SumReply]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Demo_SumServer

type Demo_SumServer = grpc.ClientStreamingServer[SumRequest, SumReply]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type HealthCheckRequest

type HealthCheckRequest struct {
	Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` // 可传具体服务名,空表示默认
	// contains filtered or unexported fields
}

========== Health ==========

func (*HealthCheckRequest) Descriptor deprecated

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

Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead.

func (*HealthCheckRequest) GetService

func (x *HealthCheckRequest) GetService() string

func (*HealthCheckRequest) ProtoMessage

func (*HealthCheckRequest) ProtoMessage()

func (*HealthCheckRequest) ProtoReflect

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

func (*HealthCheckRequest) Reset

func (x *HealthCheckRequest) Reset()

func (*HealthCheckRequest) String

func (x *HealthCheckRequest) String() string

type HealthCheckResponse

type HealthCheckResponse struct {
	Status HealthCheckResponse_Status `protobuf:"varint,1,opt,name=status,proto3,enum=test.HealthCheckResponse_Status" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*HealthCheckResponse) Descriptor deprecated

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

Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead.

func (*HealthCheckResponse) GetStatus

func (*HealthCheckResponse) ProtoMessage

func (*HealthCheckResponse) ProtoMessage()

func (*HealthCheckResponse) ProtoReflect

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

func (*HealthCheckResponse) Reset

func (x *HealthCheckResponse) Reset()

func (*HealthCheckResponse) String

func (x *HealthCheckResponse) String() string

type HealthCheckResponse_Status

type HealthCheckResponse_Status int32
const (
	HealthCheckResponse_UNKNOWN     HealthCheckResponse_Status = 0
	HealthCheckResponse_SERVING     HealthCheckResponse_Status = 1
	HealthCheckResponse_NOT_SERVING HealthCheckResponse_Status = 2
)

func (HealthCheckResponse_Status) Descriptor

func (HealthCheckResponse_Status) Enum

func (HealthCheckResponse_Status) EnumDescriptor deprecated

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

Deprecated: Use HealthCheckResponse_Status.Descriptor instead.

func (HealthCheckResponse_Status) Number

func (HealthCheckResponse_Status) String

func (HealthCheckResponse_Status) Type

type HelloReply

type HelloReply struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	TsUnix  int64  `protobuf:"varint,2,opt,name=ts_unix,json=tsUnix,proto3" json:"ts_unix,omitempty"` // 服务器时间戳
	// contains filtered or unexported fields
}

func (*HelloReply) Descriptor deprecated

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

Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.

func (*HelloReply) GetMessage

func (x *HelloReply) GetMessage() string

func (*HelloReply) GetTsUnix

func (x *HelloReply) GetTsUnix() int64

func (*HelloReply) ProtoMessage

func (*HelloReply) ProtoMessage()

func (*HelloReply) ProtoReflect

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

func (*HelloReply) Reset

func (x *HelloReply) Reset()

func (*HelloReply) String

func (x *HelloReply) String() string

type HelloRequest

type HelloRequest struct {
	Name string            `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // 测试字符串
	Meta map[string]string ``                                                              // 测试 map
	/* 135-byte string literal not displayed */
	// contains filtered or unexported fields
}

========== SayHello ==========

func (*HelloRequest) Descriptor deprecated

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

Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.

func (*HelloRequest) GetMeta

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

func (*HelloRequest) GetName

func (x *HelloRequest) GetName() string

func (*HelloRequest) ProtoMessage

func (*HelloRequest) ProtoMessage()

func (*HelloRequest) ProtoReflect

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

func (*HelloRequest) Reset

func (x *HelloRequest) Reset()

func (*HelloRequest) String

func (x *HelloRequest) String() string

type SumReply

type SumReply struct {
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` // 服务器汇总总和
	Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` // 接收了多少个包
	// contains filtered or unexported fields
}

func (*SumReply) Descriptor deprecated

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

Deprecated: Use SumReply.ProtoReflect.Descriptor instead.

func (*SumReply) GetCount

func (x *SumReply) GetCount() int32

func (*SumReply) GetTotal

func (x *SumReply) GetTotal() int64

func (*SumReply) ProtoMessage

func (*SumReply) ProtoMessage()

func (*SumReply) ProtoReflect

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

func (*SumReply) Reset

func (x *SumReply) Reset()

func (*SumReply) String

func (x *SumReply) String() string

type SumRequest

type SumRequest struct {
	Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` // 客户端不断发送的数字
	// contains filtered or unexported fields
}

========== Sum(Client streaming)==========

func (*SumRequest) Descriptor deprecated

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

Deprecated: Use SumRequest.ProtoReflect.Descriptor instead.

func (*SumRequest) GetValue

func (x *SumRequest) GetValue() int64

func (*SumRequest) ProtoMessage

func (*SumRequest) ProtoMessage()

func (*SumRequest) ProtoReflect

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

func (*SumRequest) Reset

func (x *SumRequest) Reset()

func (*SumRequest) String

func (x *SumRequest) String() string

type UnimplementedDemoServer

type UnimplementedDemoServer struct{}

UnimplementedDemoServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedDemoServer) Chat

func (UnimplementedDemoServer) Health

func (UnimplementedDemoServer) SayHello

func (UnimplementedDemoServer) Sum

type UnsafeDemoServer

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

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

Jump to

Keyboard shortcuts

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