• Home
  • Raw
  • Download

Lines Matching refs:P

100 func (g *grpc) P(args ...interface{}) { g.gen.P(args...) }  func
111 g.P("// Reference imports to suppress errors if they are not otherwise used.")
112 g.P("var _ ", contextPkg, ".Context")
113 g.P("var _ ", grpcPkg, ".ClientConn")
114 g.P()
117 g.P("// This is a compile-time assertion to ensure that this generated file")
118 g.P("// is compatible with the grpc package it is being compiled against.")
119 g.P("const _ = ", grpcPkg, ".SupportPackageIsVersion", generatedCodeVersion)
120 g.P()
154 g.P()
155 g.P(fmt.Sprintf(`// %sClient is the client API for %s service.
161 g.P("//")
162 g.P(deprecationComment)
164 g.P("type ", servName, "Client interface {")
167 g.P(g.generateClientSignature(servName, method))
169 g.P("}")
170 g.P()
173 g.P("type ", unexport(servName), "Client struct {")
174 g.P("cc *", grpcPkg, ".ClientConn")
175 g.P("}")
176 g.P()
180 g.P(deprecationComment)
182 g.P("func New", servName, "Client (cc *", grpcPkg, ".ClientConn) ", servName, "Client {")
183 g.P("return &", unexport(servName), "Client{cc}")
184 g.P("}")
185 g.P()
206 g.P("// ", serverType, " is the server API for ", servName, " service.")
208 g.P("//")
209 g.P(deprecationComment)
211 g.P("type ", serverType, " interface {")
214 g.P(g.generateServerSignature(servName, method))
216 g.P("}")
217 g.P()
221 g.P(deprecationComment)
223 g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {")
224 g.P("s.RegisterService(&", serviceDescVar, `, srv)`)
225 g.P("}")
226 g.P()
236 g.P("var ", serviceDescVar, " = ", grpcPkg, ".ServiceDesc {")
237 g.P("ServiceName: ", strconv.Quote(fullServName), ",")
238 g.P("HandlerType: (*", serverType, ")(nil),")
239 g.P("Methods: []", grpcPkg, ".MethodDesc{")
244 g.P("{")
245 g.P("MethodName: ", strconv.Quote(method.GetName()), ",")
246 g.P("Handler: ", handlerNames[i], ",")
247 g.P("},")
249 g.P("},")
250 g.P("Streams: []", grpcPkg, ".StreamDesc{")
255 g.P("{")
256 g.P("StreamName: ", strconv.Quote(method.GetName()), ",")
257 g.P("Handler: ", handlerNames[i], ",")
259 g.P("ServerStreams: true,")
262 g.P("ClientStreams: true,")
264 g.P("},")
266 g.P("},")
267 g.P("Metadata: \"", file.GetName(), "\",")
268 g.P("}")
269 g.P()
297 g.P(deprecationComment)
299 g.P("func (c *", unexport(servName), "Client) ", g.generateClientSignature(servName, method), "{")
301 g.P("out := new(", outType, ")")
303 g.P(`err := c.cc.Invoke(ctx, "`, sname, `", in, out, opts...)`)
304 g.P("if err != nil { return nil, err }")
305 g.P("return out, nil")
306 g.P("}")
307 g.P()
311 g.P("stream, err := c.cc.NewStream(ctx, ", descExpr, `, "`, sname, `", opts...)`)
312 g.P("if err != nil { return nil, err }")
313 g.P("x := &", streamType, "{stream}")
315 g.P("if err := x.ClientStream.SendMsg(in); err != nil { return nil, err }")
316 g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
318 g.P("return x, nil")
319 g.P("}")
320 g.P()
327 g.P("type ", servName, "_", methName, "Client interface {")
329 g.P("Send(*", inType, ") error")
332 g.P("Recv() (*", outType, ", error)")
335 g.P("CloseAndRecv() (*", outType, ", error)")
337 g.P(grpcPkg, ".ClientStream")
338 g.P("}")
339 g.P()
341 g.P("type ", streamType, " struct {")
342 g.P(grpcPkg, ".ClientStream")
343 g.P("}")
344 g.P()
347 g.P("func (x *", streamType, ") Send(m *", inType, ") error {")
348 g.P("return x.ClientStream.SendMsg(m)")
349 g.P("}")
350 g.P()
353 g.P("func (x *", streamType, ") Recv() (*", outType, ", error) {")
354 g.P("m := new(", outType, ")")
355 g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
356 g.P("return m, nil")
357 g.P("}")
358 g.P()
361 g.P("func (x *", streamType, ") CloseAndRecv() (*", outType, ", error) {")
362 g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
363 g.P("m := new(", outType, ")")
364 g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
365 g.P("return m, nil")
366 g.P("}")
367 g.P()
402 …g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error, …
403 g.P("in := new(", inType, ")")
404 g.P("if err := dec(in); err != nil { return nil, err }")
405 g.P("if interceptor == nil { return srv.(", servName, "Server).", methName, "(ctx, in) }")
406 g.P("info := &", grpcPkg, ".UnaryServerInfo{")
407 g.P("Server: srv,")
408 g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", fullServName, methName)), ",")
409 g.P("}")
410 g.P("handler := func(ctx ", contextPkg, ".Context, req interface{}) (interface{}, error) {")
411 g.P("return srv.(", servName, "Server).", methName, "(ctx, req.(*", inType, "))")
412 g.P("}")
413 g.P("return interceptor(ctx, in, info, handler)")
414 g.P("}")
415 g.P()
419 g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {")
421 g.P("m := new(", inType, ")")
422 g.P("if err := stream.RecvMsg(m); err != nil { return err }")
423 g.P("return srv.(", servName, "Server).", methName, "(m, &", streamType, "{stream})")
425 g.P("return srv.(", servName, "Server).", methName, "(&", streamType, "{stream})")
427 g.P("}")
428 g.P()
435 g.P("type ", servName, "_", methName, "Server interface {")
437 g.P("Send(*", outType, ") error")
440 g.P("SendAndClose(*", outType, ") error")
443 g.P("Recv() (*", inType, ", error)")
445 g.P(grpcPkg, ".ServerStream")
446 g.P("}")
447 g.P()
449 g.P("type ", streamType, " struct {")
450 g.P(grpcPkg, ".ServerStream")
451 g.P("}")
452 g.P()
455 g.P("func (x *", streamType, ") Send(m *", outType, ") error {")
456 g.P("return x.ServerStream.SendMsg(m)")
457 g.P("}")
458 g.P()
461 g.P("func (x *", streamType, ") SendAndClose(m *", outType, ") error {")
462 g.P("return x.ServerStream.SendMsg(m)")
463 g.P("}")
464 g.P()
467 g.P("func (x *", streamType, ") Recv() (*", inType, ", error) {")
468 g.P("m := new(", inType, ")")
469 g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }")
470 g.P("return m, nil")
471 g.P("}")
472 g.P()