-
Notifications
You must be signed in to change notification settings - Fork 50
Protoc output: Go
Jeff Wendling edited this page Apr 29, 2021
·
4 revisions
syntax = "proto3";
option go_package = "storj.io/drpc/internal/grpccompat";
package service;
service Service {
rpc Method1(In) returns (Out);
rpc Method2(stream In) returns (Out);
rpc Method3(In) returns (stream Out);
rpc Method4(stream In) returns (stream Out);
}
message In {
int64 in = 1;
}
message Out {
int64 out = 1;
}
var File_service_proto protoreflect.FileDescriptor
var Service_ServiceDesc grpc.ServiceDesc
func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
type ServiceClient interface {
Method1(ctx context.Context, in *In, opts ...grpc.CallOption) (*Out, error)
Method2(ctx context.Context, opts ...grpc.CallOption) (Service_Method2Client, error)
Method3(ctx context.Context, in *In, opts ...grpc.CallOption) (Service_Method3Client, error)
Method4(ctx context.Context, opts ...grpc.CallOption) (Service_Method4Client, error)
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient
type ServiceServer interface {
Method1(context.Context, *In) (*Out, error)
Method2(Service_Method2Server) error
Method3(*In, Service_Method3Server) error
Method4(Service_Method4Server) error
}
type Service_Method2Client interface {
Send(*In) error
CloseAndRecv() (*Out, error)
grpc.ClientStream
}
type Service_Method2Server interface {
SendAndClose(*Out) error
Recv() (*In, error)
grpc.ServerStream
}
type Service_Method3Client interface {
Recv() (*Out, error)
grpc.ClientStream
}
type Service_Method3Server interface {
Send(*Out) error
grpc.ServerStream
}
type Service_Method4Client interface {
Send(*In) error
Recv() (*Out, error)
grpc.ClientStream
}
type Service_Method4Server interface {
Send(*Out) error
Recv() (*In, error)
grpc.ServerStream
}
type UnimplementedServiceServer struct {}
func (UnimplementedServiceServer) Method1(context.Context, *In) (*Out, error)
func (UnimplementedServiceServer) Method2(Service_Method2Server) error
func (UnimplementedServiceServer) Method3(*In, Service_Method3Server) error
func (UnimplementedServiceServer) Method4(Service_Method4Server) error
type UnsafeServiceServer interface {}
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package grpccompat
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
// ServiceClient is the client API for Service 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 ServiceClient interface {
Method1(ctx context.Context, in *In, opts ...grpc.CallOption) (*Out, error)
Method2(ctx context.Context, opts ...grpc.CallOption) (Service_Method2Client, error)
Method3(ctx context.Context, in *In, opts ...grpc.CallOption) (Service_Method3Client, error)
Method4(ctx context.Context, opts ...grpc.CallOption) (Service_Method4Client, error)
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
func (c *serviceClient) Method1(ctx context.Context, in *In, opts ...grpc.CallOption) (*Out, error) {
out := new(Out)
err := c.cc.Invoke(ctx, "/service.Service/Method1", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *serviceClient) Method2(ctx context.Context, opts ...grpc.CallOption) (Service_Method2Client, error) {
stream, err := c.cc.NewStream(ctx, &Service_ServiceDesc.Streams[0], "/service.Service/Method2", opts...)
if err != nil {
return nil, err
}
x := &serviceMethod2Client{stream}
return x, nil
}
type Service_Method2Client interface {
Send(*In) error
CloseAndRecv() (*Out, error)
grpc.ClientStream
}
type serviceMethod2Client struct {
grpc.ClientStream
}
func (x *serviceMethod2Client) Send(m *In) error {
return x.ClientStream.SendMsg(m)
}
func (x *serviceMethod2Client) CloseAndRecv() (*Out, error) {
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
m := new(Out)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *serviceClient) Method3(ctx context.Context, in *In, opts ...grpc.CallOption) (Service_Method3Client, error) {
stream, err := c.cc.NewStream(ctx, &Service_ServiceDesc.Streams[1], "/service.Service/Method3", opts...)
if err != nil {
return nil, err
}
x := &serviceMethod3Client{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Service_Method3Client interface {
Recv() (*Out, error)
grpc.ClientStream
}
type serviceMethod3Client struct {
grpc.ClientStream
}
func (x *serviceMethod3Client) Recv() (*Out, error) {
m := new(Out)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *serviceClient) Method4(ctx context.Context, opts ...grpc.CallOption) (Service_Method4Client, error) {
stream, err := c.cc.NewStream(ctx, &Service_ServiceDesc.Streams[2], "/service.Service/Method4", opts...)
if err != nil {
return nil, err
}
x := &serviceMethod4Client{stream}
return x, nil
}
type Service_Method4Client interface {
Send(*In) error
Recv() (*Out, error)
grpc.ClientStream
}
type serviceMethod4Client struct {
grpc.ClientStream
}
func (x *serviceMethod4Client) Send(m *In) error {
return x.ClientStream.SendMsg(m)
}
func (x *serviceMethod4Client) Recv() (*Out, error) {
m := new(Out)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// ServiceServer is the server API for Service service.
// All implementations must embed UnimplementedServiceServer
// for forward compatibility
type ServiceServer interface {
Method1(context.Context, *In) (*Out, error)
Method2(Service_Method2Server) error
Method3(*In, Service_Method3Server) error
Method4(Service_Method4Server) error
mustEmbedUnimplementedServiceServer()
}
// UnimplementedServiceServer must be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func (UnimplementedServiceServer) Method1(context.Context, *In) (*Out, error) {
return nil, status.Errorf(codes.Unimplemented, "method Method1 not implemented")
}
func (UnimplementedServiceServer) Method2(Service_Method2Server) error {
return status.Errorf(codes.Unimplemented, "method Method2 not implemented")
}
func (UnimplementedServiceServer) Method3(*In, Service_Method3Server) error {
return status.Errorf(codes.Unimplemented, "method Method3 not implemented")
}
func (UnimplementedServiceServer) Method4(Service_Method4Server) error {
return status.Errorf(codes.Unimplemented, "method Method4 not implemented")
}
func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {}
// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ServiceServer will
// result in compilation errors.
type UnsafeServiceServer interface {
mustEmbedUnimplementedServiceServer()
}
func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer) {
s.RegisterService(&Service_ServiceDesc, srv)
}
func _Service_Method1_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(In)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServiceServer).Method1(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/service.Service/Method1",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServiceServer).Method1(ctx, req.(*In))
}
return interceptor(ctx, in, info, handler)
}
func _Service_Method2_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ServiceServer).Method2(&serviceMethod2Server{stream})
}
type Service_Method2Server interface {
SendAndClose(*Out) error
Recv() (*In, error)
grpc.ServerStream
}
type serviceMethod2Server struct {
grpc.ServerStream
}
func (x *serviceMethod2Server) SendAndClose(m *Out) error {
return x.ServerStream.SendMsg(m)
}
func (x *serviceMethod2Server) Recv() (*In, error) {
m := new(In)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _Service_Method3_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(In)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(ServiceServer).Method3(m, &serviceMethod3Server{stream})
}
type Service_Method3Server interface {
Send(*Out) error
grpc.ServerStream
}
type serviceMethod3Server struct {
grpc.ServerStream
}
func (x *serviceMethod3Server) Send(m *Out) error {
return x.ServerStream.SendMsg(m)
}
func _Service_Method4_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ServiceServer).Method4(&serviceMethod4Server{stream})
}
type Service_Method4Server interface {
Send(*Out) error
Recv() (*In, error)
grpc.ServerStream
}
type serviceMethod4Server struct {
grpc.ServerStream
}
func (x *serviceMethod4Server) Send(m *Out) error {
return x.ServerStream.SendMsg(m)
}
func (x *serviceMethod4Server) Recv() (*In, error) {
m := new(In)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Service_ServiceDesc is the grpc.ServiceDesc for Service service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Service_ServiceDesc = grpc.ServiceDesc{
ServiceName: "service.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Method1",
Handler: _Service_Method1_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Method2",
Handler: _Service_Method2_Handler,
ClientStreams: true,
},
{
StreamName: "Method3",
Handler: _Service_Method3_Handler,
ServerStreams: true,
},
{
StreamName: "Method4",
Handler: _Service_Method4_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "service.proto",
}