go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/internal/testpb/test_grpc.pb.go (about) 1 // Copyright 2023 The LUCI 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 // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 // versions: 17 // - protoc-gen-go-grpc v1.3.0 18 // - protoc v3.21.7 19 // source: go.chromium.org/luci/server/internal/testpb/test.proto 20 21 package testpb 22 23 import ( 24 context "context" 25 grpc "google.golang.org/grpc" 26 codes "google.golang.org/grpc/codes" 27 status "google.golang.org/grpc/status" 28 ) 29 30 // This is a compile-time assertion to ensure that this generated file 31 // is compatible with the grpc package it is being compiled against. 32 // Requires gRPC-Go v1.32.0 or later. 33 const _ = grpc.SupportPackageIsVersion7 34 35 const ( 36 Test_Unary_FullMethodName = "/testpb.Test/Unary" 37 Test_ServerStream_FullMethodName = "/testpb.Test/ServerStream" 38 Test_ClientStream_FullMethodName = "/testpb.Test/ClientStream" 39 Test_ClientServerStream_FullMethodName = "/testpb.Test/ClientServerStream" 40 ) 41 42 // TestClient is the client API for Test service. 43 // 44 // 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. 45 type TestClient interface { 46 Unary(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) 47 ServerStream(ctx context.Context, in *Request, opts ...grpc.CallOption) (Test_ServerStreamClient, error) 48 ClientStream(ctx context.Context, opts ...grpc.CallOption) (Test_ClientStreamClient, error) 49 ClientServerStream(ctx context.Context, opts ...grpc.CallOption) (Test_ClientServerStreamClient, error) 50 } 51 52 type testClient struct { 53 cc grpc.ClientConnInterface 54 } 55 56 func NewTestClient(cc grpc.ClientConnInterface) TestClient { 57 return &testClient{cc} 58 } 59 60 func (c *testClient) Unary(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { 61 out := new(Response) 62 err := c.cc.Invoke(ctx, Test_Unary_FullMethodName, in, out, opts...) 63 if err != nil { 64 return nil, err 65 } 66 return out, nil 67 } 68 69 func (c *testClient) ServerStream(ctx context.Context, in *Request, opts ...grpc.CallOption) (Test_ServerStreamClient, error) { 70 stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[0], Test_ServerStream_FullMethodName, opts...) 71 if err != nil { 72 return nil, err 73 } 74 x := &testServerStreamClient{stream} 75 if err := x.ClientStream.SendMsg(in); err != nil { 76 return nil, err 77 } 78 if err := x.ClientStream.CloseSend(); err != nil { 79 return nil, err 80 } 81 return x, nil 82 } 83 84 type Test_ServerStreamClient interface { 85 Recv() (*Response, error) 86 grpc.ClientStream 87 } 88 89 type testServerStreamClient struct { 90 grpc.ClientStream 91 } 92 93 func (x *testServerStreamClient) Recv() (*Response, error) { 94 m := new(Response) 95 if err := x.ClientStream.RecvMsg(m); err != nil { 96 return nil, err 97 } 98 return m, nil 99 } 100 101 func (c *testClient) ClientStream(ctx context.Context, opts ...grpc.CallOption) (Test_ClientStreamClient, error) { 102 stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[1], Test_ClientStream_FullMethodName, opts...) 103 if err != nil { 104 return nil, err 105 } 106 x := &testClientStreamClient{stream} 107 return x, nil 108 } 109 110 type Test_ClientStreamClient interface { 111 Send(*Request) error 112 CloseAndRecv() (*Response, error) 113 grpc.ClientStream 114 } 115 116 type testClientStreamClient struct { 117 grpc.ClientStream 118 } 119 120 func (x *testClientStreamClient) Send(m *Request) error { 121 return x.ClientStream.SendMsg(m) 122 } 123 124 func (x *testClientStreamClient) CloseAndRecv() (*Response, error) { 125 if err := x.ClientStream.CloseSend(); err != nil { 126 return nil, err 127 } 128 m := new(Response) 129 if err := x.ClientStream.RecvMsg(m); err != nil { 130 return nil, err 131 } 132 return m, nil 133 } 134 135 func (c *testClient) ClientServerStream(ctx context.Context, opts ...grpc.CallOption) (Test_ClientServerStreamClient, error) { 136 stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[2], Test_ClientServerStream_FullMethodName, opts...) 137 if err != nil { 138 return nil, err 139 } 140 x := &testClientServerStreamClient{stream} 141 return x, nil 142 } 143 144 type Test_ClientServerStreamClient interface { 145 Send(*Request) error 146 Recv() (*Response, error) 147 grpc.ClientStream 148 } 149 150 type testClientServerStreamClient struct { 151 grpc.ClientStream 152 } 153 154 func (x *testClientServerStreamClient) Send(m *Request) error { 155 return x.ClientStream.SendMsg(m) 156 } 157 158 func (x *testClientServerStreamClient) Recv() (*Response, error) { 159 m := new(Response) 160 if err := x.ClientStream.RecvMsg(m); err != nil { 161 return nil, err 162 } 163 return m, nil 164 } 165 166 // TestServer is the server API for Test service. 167 // All implementations must embed UnimplementedTestServer 168 // for forward compatibility 169 type TestServer interface { 170 Unary(context.Context, *Request) (*Response, error) 171 ServerStream(*Request, Test_ServerStreamServer) error 172 ClientStream(Test_ClientStreamServer) error 173 ClientServerStream(Test_ClientServerStreamServer) error 174 mustEmbedUnimplementedTestServer() 175 } 176 177 // UnimplementedTestServer must be embedded to have forward compatible implementations. 178 type UnimplementedTestServer struct { 179 } 180 181 func (UnimplementedTestServer) Unary(context.Context, *Request) (*Response, error) { 182 return nil, status.Errorf(codes.Unimplemented, "method Unary not implemented") 183 } 184 func (UnimplementedTestServer) ServerStream(*Request, Test_ServerStreamServer) error { 185 return status.Errorf(codes.Unimplemented, "method ServerStream not implemented") 186 } 187 func (UnimplementedTestServer) ClientStream(Test_ClientStreamServer) error { 188 return status.Errorf(codes.Unimplemented, "method ClientStream not implemented") 189 } 190 func (UnimplementedTestServer) ClientServerStream(Test_ClientServerStreamServer) error { 191 return status.Errorf(codes.Unimplemented, "method ClientServerStream not implemented") 192 } 193 func (UnimplementedTestServer) mustEmbedUnimplementedTestServer() {} 194 195 // UnsafeTestServer may be embedded to opt out of forward compatibility for this service. 196 // Use of this interface is not recommended, as added methods to TestServer will 197 // result in compilation errors. 198 type UnsafeTestServer interface { 199 mustEmbedUnimplementedTestServer() 200 } 201 202 func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer) { 203 s.RegisterService(&Test_ServiceDesc, srv) 204 } 205 206 func _Test_Unary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 207 in := new(Request) 208 if err := dec(in); err != nil { 209 return nil, err 210 } 211 if interceptor == nil { 212 return srv.(TestServer).Unary(ctx, in) 213 } 214 info := &grpc.UnaryServerInfo{ 215 Server: srv, 216 FullMethod: Test_Unary_FullMethodName, 217 } 218 handler := func(ctx context.Context, req interface{}) (interface{}, error) { 219 return srv.(TestServer).Unary(ctx, req.(*Request)) 220 } 221 return interceptor(ctx, in, info, handler) 222 } 223 224 func _Test_ServerStream_Handler(srv interface{}, stream grpc.ServerStream) error { 225 m := new(Request) 226 if err := stream.RecvMsg(m); err != nil { 227 return err 228 } 229 return srv.(TestServer).ServerStream(m, &testServerStreamServer{stream}) 230 } 231 232 type Test_ServerStreamServer interface { 233 Send(*Response) error 234 grpc.ServerStream 235 } 236 237 type testServerStreamServer struct { 238 grpc.ServerStream 239 } 240 241 func (x *testServerStreamServer) Send(m *Response) error { 242 return x.ServerStream.SendMsg(m) 243 } 244 245 func _Test_ClientStream_Handler(srv interface{}, stream grpc.ServerStream) error { 246 return srv.(TestServer).ClientStream(&testClientStreamServer{stream}) 247 } 248 249 type Test_ClientStreamServer interface { 250 SendAndClose(*Response) error 251 Recv() (*Request, error) 252 grpc.ServerStream 253 } 254 255 type testClientStreamServer struct { 256 grpc.ServerStream 257 } 258 259 func (x *testClientStreamServer) SendAndClose(m *Response) error { 260 return x.ServerStream.SendMsg(m) 261 } 262 263 func (x *testClientStreamServer) Recv() (*Request, error) { 264 m := new(Request) 265 if err := x.ServerStream.RecvMsg(m); err != nil { 266 return nil, err 267 } 268 return m, nil 269 } 270 271 func _Test_ClientServerStream_Handler(srv interface{}, stream grpc.ServerStream) error { 272 return srv.(TestServer).ClientServerStream(&testClientServerStreamServer{stream}) 273 } 274 275 type Test_ClientServerStreamServer interface { 276 Send(*Response) error 277 Recv() (*Request, error) 278 grpc.ServerStream 279 } 280 281 type testClientServerStreamServer struct { 282 grpc.ServerStream 283 } 284 285 func (x *testClientServerStreamServer) Send(m *Response) error { 286 return x.ServerStream.SendMsg(m) 287 } 288 289 func (x *testClientServerStreamServer) Recv() (*Request, error) { 290 m := new(Request) 291 if err := x.ServerStream.RecvMsg(m); err != nil { 292 return nil, err 293 } 294 return m, nil 295 } 296 297 // Test_ServiceDesc is the grpc.ServiceDesc for Test service. 298 // It's only intended for direct use with grpc.RegisterService, 299 // and not to be introspected or modified (even as a copy) 300 var Test_ServiceDesc = grpc.ServiceDesc{ 301 ServiceName: "testpb.Test", 302 HandlerType: (*TestServer)(nil), 303 Methods: []grpc.MethodDesc{ 304 { 305 MethodName: "Unary", 306 Handler: _Test_Unary_Handler, 307 }, 308 }, 309 Streams: []grpc.StreamDesc{ 310 { 311 StreamName: "ServerStream", 312 Handler: _Test_ServerStream_Handler, 313 ServerStreams: true, 314 }, 315 { 316 StreamName: "ClientStream", 317 Handler: _Test_ClientStream_Handler, 318 ClientStreams: true, 319 }, 320 { 321 StreamName: "ClientServerStream", 322 Handler: _Test_ClientServerStream_Handler, 323 ServerStreams: true, 324 ClientStreams: true, 325 }, 326 }, 327 Metadata: "go.chromium.org/luci/server/internal/testpb/test.proto", 328 }