...

Source file src/google.golang.org/grpc/interop/grpc_testing/benchmark_service_grpc.pb.go

Documentation: google.golang.org/grpc/interop/grpc_testing

     1  // Copyright 2015 gRPC authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // An integration test service that covers all the method signature permutations
    16  // of unary/streaming requests/responses.
    17  
    18  // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
    19  // versions:
    20  // - protoc-gen-go-grpc v1.3.0
    21  // - protoc             v4.25.2
    22  // source: grpc/testing/benchmark_service.proto
    23  
    24  package grpc_testing
    25  
    26  import (
    27  	context "context"
    28  	grpc "google.golang.org/grpc"
    29  	codes "google.golang.org/grpc/codes"
    30  	status "google.golang.org/grpc/status"
    31  )
    32  
    33  // This is a compile-time assertion to ensure that this generated file
    34  // is compatible with the grpc package it is being compiled against.
    35  // Requires gRPC-Go v1.64.0 or later.
    36  const _ = grpc.SupportPackageIsVersion9
    37  
    38  const (
    39  	BenchmarkService_UnaryCall_FullMethodName           = "/grpc.testing.BenchmarkService/UnaryCall"
    40  	BenchmarkService_StreamingCall_FullMethodName       = "/grpc.testing.BenchmarkService/StreamingCall"
    41  	BenchmarkService_StreamingFromClient_FullMethodName = "/grpc.testing.BenchmarkService/StreamingFromClient"
    42  	BenchmarkService_StreamingFromServer_FullMethodName = "/grpc.testing.BenchmarkService/StreamingFromServer"
    43  	BenchmarkService_StreamingBothWays_FullMethodName   = "/grpc.testing.BenchmarkService/StreamingBothWays"
    44  )
    45  
    46  // BenchmarkServiceClient is the client API for BenchmarkService service.
    47  //
    48  // 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.
    49  type BenchmarkServiceClient interface {
    50  	// One request followed by one response.
    51  	// The server returns the client payload as-is.
    52  	UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error)
    53  	// Repeated sequence of one request followed by one response.
    54  	// Should be called streaming ping-pong
    55  	// The server returns the client payload as-is on each response
    56  	StreamingCall(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[SimpleRequest, SimpleResponse], error)
    57  	// Single-sided unbounded streaming from client to server
    58  	// The server returns the client payload as-is once the client does WritesDone
    59  	StreamingFromClient(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[SimpleRequest, SimpleResponse], error)
    60  	// Single-sided unbounded streaming from server to client
    61  	// The server repeatedly returns the client payload as-is
    62  	StreamingFromServer(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SimpleResponse], error)
    63  	// Two-sided unbounded streaming between server to client
    64  	// Both sides send the content of their own choice to the other
    65  	StreamingBothWays(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[SimpleRequest, SimpleResponse], error)
    66  }
    67  
    68  type benchmarkServiceClient struct {
    69  	cc grpc.ClientConnInterface
    70  }
    71  
    72  func NewBenchmarkServiceClient(cc grpc.ClientConnInterface) BenchmarkServiceClient {
    73  	return &benchmarkServiceClient{cc}
    74  }
    75  
    76  func (c *benchmarkServiceClient) UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error) {
    77  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
    78  	out := new(SimpleResponse)
    79  	err := c.cc.Invoke(ctx, BenchmarkService_UnaryCall_FullMethodName, in, out, cOpts...)
    80  	if err != nil {
    81  		return nil, err
    82  	}
    83  	return out, nil
    84  }
    85  
    86  func (c *benchmarkServiceClient) StreamingCall(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[SimpleRequest, SimpleResponse], error) {
    87  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
    88  	stream, err := c.cc.NewStream(ctx, &BenchmarkService_ServiceDesc.Streams[0], BenchmarkService_StreamingCall_FullMethodName, cOpts...)
    89  	if err != nil {
    90  		return nil, err
    91  	}
    92  	x := &grpc.GenericClientStream[SimpleRequest, SimpleResponse]{ClientStream: stream}
    93  	return x, nil
    94  }
    95  
    96  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
    97  type BenchmarkService_StreamingCallClient = grpc.BidiStreamingClient[SimpleRequest, SimpleResponse]
    98  
    99  func (c *benchmarkServiceClient) StreamingFromClient(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[SimpleRequest, SimpleResponse], error) {
   100  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   101  	stream, err := c.cc.NewStream(ctx, &BenchmarkService_ServiceDesc.Streams[1], BenchmarkService_StreamingFromClient_FullMethodName, cOpts...)
   102  	if err != nil {
   103  		return nil, err
   104  	}
   105  	x := &grpc.GenericClientStream[SimpleRequest, SimpleResponse]{ClientStream: stream}
   106  	return x, nil
   107  }
   108  
   109  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   110  type BenchmarkService_StreamingFromClientClient = grpc.ClientStreamingClient[SimpleRequest, SimpleResponse]
   111  
   112  func (c *benchmarkServiceClient) StreamingFromServer(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[SimpleResponse], error) {
   113  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   114  	stream, err := c.cc.NewStream(ctx, &BenchmarkService_ServiceDesc.Streams[2], BenchmarkService_StreamingFromServer_FullMethodName, cOpts...)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	x := &grpc.GenericClientStream[SimpleRequest, SimpleResponse]{ClientStream: stream}
   119  	if err := x.ClientStream.SendMsg(in); err != nil {
   120  		return nil, err
   121  	}
   122  	if err := x.ClientStream.CloseSend(); err != nil {
   123  		return nil, err
   124  	}
   125  	return x, nil
   126  }
   127  
   128  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   129  type BenchmarkService_StreamingFromServerClient = grpc.ServerStreamingClient[SimpleResponse]
   130  
   131  func (c *benchmarkServiceClient) StreamingBothWays(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[SimpleRequest, SimpleResponse], error) {
   132  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   133  	stream, err := c.cc.NewStream(ctx, &BenchmarkService_ServiceDesc.Streams[3], BenchmarkService_StreamingBothWays_FullMethodName, cOpts...)
   134  	if err != nil {
   135  		return nil, err
   136  	}
   137  	x := &grpc.GenericClientStream[SimpleRequest, SimpleResponse]{ClientStream: stream}
   138  	return x, nil
   139  }
   140  
   141  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   142  type BenchmarkService_StreamingBothWaysClient = grpc.BidiStreamingClient[SimpleRequest, SimpleResponse]
   143  
   144  // BenchmarkServiceServer is the server API for BenchmarkService service.
   145  // All implementations must embed UnimplementedBenchmarkServiceServer
   146  // for forward compatibility
   147  type BenchmarkServiceServer interface {
   148  	// One request followed by one response.
   149  	// The server returns the client payload as-is.
   150  	UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
   151  	// Repeated sequence of one request followed by one response.
   152  	// Should be called streaming ping-pong
   153  	// The server returns the client payload as-is on each response
   154  	StreamingCall(grpc.BidiStreamingServer[SimpleRequest, SimpleResponse]) error
   155  	// Single-sided unbounded streaming from client to server
   156  	// The server returns the client payload as-is once the client does WritesDone
   157  	StreamingFromClient(grpc.ClientStreamingServer[SimpleRequest, SimpleResponse]) error
   158  	// Single-sided unbounded streaming from server to client
   159  	// The server repeatedly returns the client payload as-is
   160  	StreamingFromServer(*SimpleRequest, grpc.ServerStreamingServer[SimpleResponse]) error
   161  	// Two-sided unbounded streaming between server to client
   162  	// Both sides send the content of their own choice to the other
   163  	StreamingBothWays(grpc.BidiStreamingServer[SimpleRequest, SimpleResponse]) error
   164  	mustEmbedUnimplementedBenchmarkServiceServer()
   165  }
   166  
   167  // UnimplementedBenchmarkServiceServer must be embedded to have forward compatible implementations.
   168  type UnimplementedBenchmarkServiceServer struct {
   169  }
   170  
   171  func (UnimplementedBenchmarkServiceServer) UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error) {
   172  	return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
   173  }
   174  func (UnimplementedBenchmarkServiceServer) StreamingCall(grpc.BidiStreamingServer[SimpleRequest, SimpleResponse]) error {
   175  	return status.Errorf(codes.Unimplemented, "method StreamingCall not implemented")
   176  }
   177  func (UnimplementedBenchmarkServiceServer) StreamingFromClient(grpc.ClientStreamingServer[SimpleRequest, SimpleResponse]) error {
   178  	return status.Errorf(codes.Unimplemented, "method StreamingFromClient not implemented")
   179  }
   180  func (UnimplementedBenchmarkServiceServer) StreamingFromServer(*SimpleRequest, grpc.ServerStreamingServer[SimpleResponse]) error {
   181  	return status.Errorf(codes.Unimplemented, "method StreamingFromServer not implemented")
   182  }
   183  func (UnimplementedBenchmarkServiceServer) StreamingBothWays(grpc.BidiStreamingServer[SimpleRequest, SimpleResponse]) error {
   184  	return status.Errorf(codes.Unimplemented, "method StreamingBothWays not implemented")
   185  }
   186  func (UnimplementedBenchmarkServiceServer) mustEmbedUnimplementedBenchmarkServiceServer() {}
   187  
   188  // UnsafeBenchmarkServiceServer may be embedded to opt out of forward compatibility for this service.
   189  // Use of this interface is not recommended, as added methods to BenchmarkServiceServer will
   190  // result in compilation errors.
   191  type UnsafeBenchmarkServiceServer interface {
   192  	mustEmbedUnimplementedBenchmarkServiceServer()
   193  }
   194  
   195  func RegisterBenchmarkServiceServer(s grpc.ServiceRegistrar, srv BenchmarkServiceServer) {
   196  	s.RegisterService(&BenchmarkService_ServiceDesc, srv)
   197  }
   198  
   199  func _BenchmarkService_UnaryCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   200  	in := new(SimpleRequest)
   201  	if err := dec(in); err != nil {
   202  		return nil, err
   203  	}
   204  	if interceptor == nil {
   205  		return srv.(BenchmarkServiceServer).UnaryCall(ctx, in)
   206  	}
   207  	info := &grpc.UnaryServerInfo{
   208  		Server:     srv,
   209  		FullMethod: BenchmarkService_UnaryCall_FullMethodName,
   210  	}
   211  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   212  		return srv.(BenchmarkServiceServer).UnaryCall(ctx, req.(*SimpleRequest))
   213  	}
   214  	return interceptor(ctx, in, info, handler)
   215  }
   216  
   217  func _BenchmarkService_StreamingCall_Handler(srv interface{}, stream grpc.ServerStream) error {
   218  	return srv.(BenchmarkServiceServer).StreamingCall(&grpc.GenericServerStream[SimpleRequest, SimpleResponse]{ServerStream: stream})
   219  }
   220  
   221  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   222  type BenchmarkService_StreamingCallServer = grpc.BidiStreamingServer[SimpleRequest, SimpleResponse]
   223  
   224  func _BenchmarkService_StreamingFromClient_Handler(srv interface{}, stream grpc.ServerStream) error {
   225  	return srv.(BenchmarkServiceServer).StreamingFromClient(&grpc.GenericServerStream[SimpleRequest, SimpleResponse]{ServerStream: stream})
   226  }
   227  
   228  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   229  type BenchmarkService_StreamingFromClientServer = grpc.ClientStreamingServer[SimpleRequest, SimpleResponse]
   230  
   231  func _BenchmarkService_StreamingFromServer_Handler(srv interface{}, stream grpc.ServerStream) error {
   232  	m := new(SimpleRequest)
   233  	if err := stream.RecvMsg(m); err != nil {
   234  		return err
   235  	}
   236  	return srv.(BenchmarkServiceServer).StreamingFromServer(m, &grpc.GenericServerStream[SimpleRequest, SimpleResponse]{ServerStream: stream})
   237  }
   238  
   239  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   240  type BenchmarkService_StreamingFromServerServer = grpc.ServerStreamingServer[SimpleResponse]
   241  
   242  func _BenchmarkService_StreamingBothWays_Handler(srv interface{}, stream grpc.ServerStream) error {
   243  	return srv.(BenchmarkServiceServer).StreamingBothWays(&grpc.GenericServerStream[SimpleRequest, SimpleResponse]{ServerStream: stream})
   244  }
   245  
   246  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   247  type BenchmarkService_StreamingBothWaysServer = grpc.BidiStreamingServer[SimpleRequest, SimpleResponse]
   248  
   249  // BenchmarkService_ServiceDesc is the grpc.ServiceDesc for BenchmarkService service.
   250  // It's only intended for direct use with grpc.RegisterService,
   251  // and not to be introspected or modified (even as a copy)
   252  var BenchmarkService_ServiceDesc = grpc.ServiceDesc{
   253  	ServiceName: "grpc.testing.BenchmarkService",
   254  	HandlerType: (*BenchmarkServiceServer)(nil),
   255  	Methods: []grpc.MethodDesc{
   256  		{
   257  			MethodName: "UnaryCall",
   258  			Handler:    _BenchmarkService_UnaryCall_Handler,
   259  		},
   260  	},
   261  	Streams: []grpc.StreamDesc{
   262  		{
   263  			StreamName:    "StreamingCall",
   264  			Handler:       _BenchmarkService_StreamingCall_Handler,
   265  			ServerStreams: true,
   266  			ClientStreams: true,
   267  		},
   268  		{
   269  			StreamName:    "StreamingFromClient",
   270  			Handler:       _BenchmarkService_StreamingFromClient_Handler,
   271  			ClientStreams: true,
   272  		},
   273  		{
   274  			StreamName:    "StreamingFromServer",
   275  			Handler:       _BenchmarkService_StreamingFromServer_Handler,
   276  			ServerStreams: true,
   277  		},
   278  		{
   279  			StreamName:    "StreamingBothWays",
   280  			Handler:       _BenchmarkService_StreamingBothWays_Handler,
   281  			ServerStreams: true,
   282  			ClientStreams: true,
   283  		},
   284  	},
   285  	Metadata: "grpc/testing/benchmark_service.proto",
   286  }
   287  

View as plain text