5 Star 14 Fork 12

go-course / go12

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rpc_grpc.pb.go 3.74 KB
一键复制 编辑 原始数据 按行查看 历史
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.21.12
// source: apps/comment/pb/rpc.proto
package comment
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
RPC_CreateComment_FullMethodName = "/comment.RPC/CreateComment"
)
// RPCClient is the client API for RPC 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 RPCClient interface {
// comment.Comment, rpc.proto/model.proto 属于同一包: comment
// 同名包下面的message 引入后可以直接使用, 不用添加包名称
CreateComment(ctx context.Context, in *CreateCommentRequest, opts ...grpc.CallOption) (*Comment, error)
}
type rPCClient struct {
cc grpc.ClientConnInterface
}
func NewRPCClient(cc grpc.ClientConnInterface) RPCClient {
return &rPCClient{cc}
}
func (c *rPCClient) CreateComment(ctx context.Context, in *CreateCommentRequest, opts ...grpc.CallOption) (*Comment, error) {
out := new(Comment)
err := c.cc.Invoke(ctx, RPC_CreateComment_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RPCServer is the server API for RPC service.
// All implementations must embed UnimplementedRPCServer
// for forward compatibility
type RPCServer interface {
// comment.Comment, rpc.proto/model.proto 属于同一包: comment
// 同名包下面的message 引入后可以直接使用, 不用添加包名称
CreateComment(context.Context, *CreateCommentRequest) (*Comment, error)
mustEmbedUnimplementedRPCServer()
}
// UnimplementedRPCServer must be embedded to have forward compatible implementations.
type UnimplementedRPCServer struct {
}
func (UnimplementedRPCServer) CreateComment(context.Context, *CreateCommentRequest) (*Comment, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateComment not implemented")
}
func (UnimplementedRPCServer) mustEmbedUnimplementedRPCServer() {}
// UnsafeRPCServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to RPCServer will
// result in compilation errors.
type UnsafeRPCServer interface {
mustEmbedUnimplementedRPCServer()
}
func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer) {
s.RegisterService(&RPC_ServiceDesc, srv)
}
func _RPC_CreateComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateCommentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RPCServer).CreateComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: RPC_CreateComment_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RPCServer).CreateComment(ctx, req.(*CreateCommentRequest))
}
return interceptor(ctx, in, info, handler)
}
// RPC_ServiceDesc is the grpc.ServiceDesc for RPC service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RPC_ServiceDesc = grpc.ServiceDesc{
ServiceName: "comment.RPC",
HandlerType: (*RPCServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateComment",
Handler: _RPC_CreateComment_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "apps/comment/pb/rpc.proto",
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/go-course/go12.git
git@gitee.com:go-course/go12.git
go-course
go12
go12
8a8b3aa3c2e4

搜索帮助