t/grpc_server_example/proto/echo_grpc.pb.go (70 lines of code) (raw):
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.6.1
// source: proto/echo.proto
package proto
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
// EchoClient is the client API for Echo 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 EchoClient interface {
EchoStruct(ctx context.Context, in *StructRequest, opts ...grpc.CallOption) (*StructReply, error)
}
type echoClient struct {
cc grpc.ClientConnInterface
}
func NewEchoClient(cc grpc.ClientConnInterface) EchoClient {
return &echoClient{cc}
}
func (c *echoClient) EchoStruct(ctx context.Context, in *StructRequest, opts ...grpc.CallOption) (*StructReply, error) {
out := new(StructReply)
err := c.cc.Invoke(ctx, "/echo.Echo/EchoStruct", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// EchoServer is the server API for Echo service.
// All implementations must embed UnimplementedEchoServer
// for forward compatibility
type EchoServer interface {
EchoStruct(context.Context, *StructRequest) (*StructReply, error)
mustEmbedUnimplementedEchoServer()
}
// UnimplementedEchoServer must be embedded to have forward compatible implementations.
type UnimplementedEchoServer struct {
}
func (UnimplementedEchoServer) EchoStruct(context.Context, *StructRequest) (*StructReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method EchoStruct not implemented")
}
func (UnimplementedEchoServer) mustEmbedUnimplementedEchoServer() {}
// UnsafeEchoServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to EchoServer will
// result in compilation errors.
type UnsafeEchoServer interface {
mustEmbedUnimplementedEchoServer()
}
func RegisterEchoServer(s grpc.ServiceRegistrar, srv EchoServer) {
s.RegisterService(&Echo_ServiceDesc, srv)
}
func _Echo_EchoStruct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StructRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EchoServer).EchoStruct(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/echo.Echo/EchoStruct",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EchoServer).EchoStruct(ctx, req.(*StructRequest))
}
return interceptor(ctx, in, info, handler)
}
// Echo_ServiceDesc is the grpc.ServiceDesc for Echo service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Echo_ServiceDesc = grpc.ServiceDesc{
ServiceName: "echo.Echo",
HandlerType: (*EchoServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "EchoStruct",
Handler: _Echo_EchoStruct_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "proto/echo.proto",
}