rpc/triple/stream/proto/greet.triple.go (305 lines of code) (raw):

// Code generated by protoc-gen-triple. DO NOT EDIT. // // Source: greet.proto package greet import ( "context" "net/http" ) import ( "dubbo.apache.org/dubbo-go/v3" "dubbo.apache.org/dubbo-go/v3/client" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol" "dubbo.apache.org/dubbo-go/v3/server" ) // This is a compile-time assertion to ensure that this generated file and the Triple package // are compatible. If you get a compiler error that this constant is not defined, this code was // generated with a version of Triple newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of Triple or updating the Triple // version compiled into your binary. const _ = triple_protocol.IsAtLeastVersion0_1_0 const ( // GreetServiceName is the fully-qualified name of the GreetService service. GreetServiceName = "greet.GreetService" ) // These constants are the fully-qualified names of the RPCs defined in this package. They're // exposed at runtime as procedure and as the final two segments of the HTTP route. // // Note that these are different from the fully-qualified method names used by // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to // reflection-formatted method names, remove the leading slash and convert the remaining slash to a // period. const ( // GreetServiceGreetProcedure is the fully-qualified name of the GreetService's Greet RPC. GreetServiceGreetProcedure = "/greet.GreetService/Greet" // GreetServiceGreetStreamProcedure is the fully-qualified name of the GreetService's GreetStream RPC. GreetServiceGreetStreamProcedure = "/greet.GreetService/GreetStream" // GreetServiceGreetClientStreamProcedure is the fully-qualified name of the GreetService's GreetClientStream RPC. GreetServiceGreetClientStreamProcedure = "/greet.GreetService/GreetClientStream" // GreetServiceGreetServerStreamProcedure is the fully-qualified name of the GreetService's GreetServerStream RPC. GreetServiceGreetServerStreamProcedure = "/greet.GreetService/GreetServerStream" ) var ( _ GreetService = (*GreetServiceImpl)(nil) _ GreetService_GreetStreamClient = (*GreetServiceGreetStreamClient)(nil) _ GreetService_GreetClientStreamClient = (*GreetServiceGreetClientStreamClient)(nil) _ GreetService_GreetServerStreamClient = (*GreetServiceGreetServerStreamClient)(nil) _ GreetService_GreetStreamServer = (*GreetServiceGreetStreamServer)(nil) _ GreetService_GreetClientStreamServer = (*GreetServiceGreetClientStreamServer)(nil) _ GreetService_GreetServerStreamServer = (*GreetServiceGreetServerStreamServer)(nil) ) // GreetService is a client for the greet.GreetService service. type GreetService interface { Greet(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error) GreetStream(ctx context.Context, opts ...client.CallOption) (GreetService_GreetStreamClient, error) GreetClientStream(ctx context.Context, opts ...client.CallOption) (GreetService_GreetClientStreamClient, error) GreetServerStream(ctx context.Context, req *GreetServerStreamRequest, opts ...client.CallOption) (GreetService_GreetServerStreamClient, error) } // NewGreetService constructs a client for the greet.GreetService service. func NewGreetService(cli *client.Client, opts ...client.ReferenceOption) (GreetService, error) { conn, err := cli.DialWithInfo("greet.GreetService", &GreetService_ClientInfo, opts...) if err != nil { return nil, err } return &GreetServiceImpl{ conn: conn, }, nil } func SetConsumerGreetService(srv common.RPCService) { dubbo.SetConsumerServiceWithInfo(srv, &GreetService_ClientInfo) } // GreetServiceImpl implements GreetService. type GreetServiceImpl struct { conn *client.Connection } func (c *GreetServiceImpl) Greet(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error) { resp := new(GreetResponse) if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "Greet", opts...); err != nil { return nil, err } return resp, nil } func (c *GreetServiceImpl) GreetStream(ctx context.Context, opts ...client.CallOption) (GreetService_GreetStreamClient, error) { stream, err := c.conn.CallBidiStream(ctx, "GreetStream", opts...) if err != nil { return nil, err } rawStream := stream.(*triple_protocol.BidiStreamForClient) return &GreetServiceGreetStreamClient{rawStream}, nil } func (c *GreetServiceImpl) GreetClientStream(ctx context.Context, opts ...client.CallOption) (GreetService_GreetClientStreamClient, error) { stream, err := c.conn.CallClientStream(ctx, "GreetClientStream", opts...) if err != nil { return nil, err } rawStream := stream.(*triple_protocol.ClientStreamForClient) return &GreetServiceGreetClientStreamClient{rawStream}, nil } func (c *GreetServiceImpl) GreetServerStream(ctx context.Context, req *GreetServerStreamRequest, opts ...client.CallOption) (GreetService_GreetServerStreamClient, error) { stream, err := c.conn.CallServerStream(ctx, req, "GreetServerStream", opts...) if err != nil { return nil, err } rawStream := stream.(*triple_protocol.ServerStreamForClient) return &GreetServiceGreetServerStreamClient{rawStream}, nil } type GreetService_GreetStreamClient interface { Spec() triple_protocol.Spec Peer() triple_protocol.Peer Send(*GreetStreamRequest) error RequestHeader() http.Header CloseRequest() error Recv() (*GreetStreamResponse, error) ResponseHeader() http.Header ResponseTrailer() http.Header CloseResponse() error } type GreetServiceGreetStreamClient struct { *triple_protocol.BidiStreamForClient } func (cli *GreetServiceGreetStreamClient) Send(msg *GreetStreamRequest) error { return cli.BidiStreamForClient.Send(msg) } func (cli *GreetServiceGreetStreamClient) Recv() (*GreetStreamResponse, error) { msg := new(GreetStreamResponse) if err := cli.BidiStreamForClient.Receive(msg); err != nil { return nil, err } return msg, nil } type GreetService_GreetClientStreamClient interface { Spec() triple_protocol.Spec Peer() triple_protocol.Peer Send(*GreetClientStreamRequest) error RequestHeader() http.Header CloseAndRecv() (*GreetClientStreamResponse, error) Conn() (triple_protocol.StreamingClientConn, error) } type GreetServiceGreetClientStreamClient struct { *triple_protocol.ClientStreamForClient } func (cli *GreetServiceGreetClientStreamClient) Send(msg *GreetClientStreamRequest) error { return cli.ClientStreamForClient.Send(msg) } func (cli *GreetServiceGreetClientStreamClient) CloseAndRecv() (*GreetClientStreamResponse, error) { msg := new(GreetClientStreamResponse) resp := triple_protocol.NewResponse(msg) if err := cli.ClientStreamForClient.CloseAndReceive(resp); err != nil { return nil, err } return msg, nil } func (cli *GreetServiceGreetClientStreamClient) Conn() (triple_protocol.StreamingClientConn, error) { return cli.ClientStreamForClient.Conn() } type GreetService_GreetServerStreamClient interface { Recv() bool ResponseHeader() http.Header ResponseTrailer() http.Header Msg() *GreetServerStreamResponse Err() error Conn() (triple_protocol.StreamingClientConn, error) Close() error } type GreetServiceGreetServerStreamClient struct { *triple_protocol.ServerStreamForClient } func (cli *GreetServiceGreetServerStreamClient) Recv() bool { msg := new(GreetServerStreamResponse) return cli.ServerStreamForClient.Receive(msg) } func (cli *GreetServiceGreetServerStreamClient) Msg() *GreetServerStreamResponse { msg := cli.ServerStreamForClient.Msg() if msg == nil { return new(GreetServerStreamResponse) } return msg.(*GreetServerStreamResponse) } func (cli *GreetServiceGreetServerStreamClient) Conn() (triple_protocol.StreamingClientConn, error) { return cli.ServerStreamForClient.Conn() } var GreetService_ClientInfo = client.ClientInfo{ InterfaceName: "greet.GreetService", MethodNames: []string{"Greet", "GreetStream", "GreetClientStream", "GreetServerStream"}, ConnectionInjectFunc: func(dubboCliRaw interface{}, conn *client.Connection) { dubboCli := dubboCliRaw.(*GreetServiceImpl) dubboCli.conn = conn }, } // GreetServiceHandler is an implementation of the greet.GreetService service. type GreetServiceHandler interface { Greet(context.Context, *GreetRequest) (*GreetResponse, error) GreetStream(context.Context, GreetService_GreetStreamServer) error GreetClientStream(context.Context, GreetService_GreetClientStreamServer) (*GreetClientStreamResponse, error) GreetServerStream(context.Context, *GreetServerStreamRequest, GreetService_GreetServerStreamServer) error } func RegisterGreetServiceHandler(srv *server.Server, hdlr GreetServiceHandler, opts ...server.ServiceOption) error { return srv.Register(hdlr, &GreetService_ServiceInfo, opts...) } func SetProviderGreetService(srv common.RPCService) { dubbo.SetProviderServiceWithInfo(srv, &GreetService_ServiceInfo) } type GreetService_GreetStreamServer interface { Send(*GreetStreamResponse) error Recv() (*GreetStreamRequest, error) Spec() triple_protocol.Spec Peer() triple_protocol.Peer RequestHeader() http.Header ResponseHeader() http.Header ResponseTrailer() http.Header Conn() triple_protocol.StreamingHandlerConn } type GreetServiceGreetStreamServer struct { *triple_protocol.BidiStream } func (srv *GreetServiceGreetStreamServer) Send(msg *GreetStreamResponse) error { return srv.BidiStream.Send(msg) } func (srv GreetServiceGreetStreamServer) Recv() (*GreetStreamRequest, error) { msg := new(GreetStreamRequest) if err := srv.BidiStream.Receive(msg); err != nil { return nil, err } return msg, nil } type GreetService_GreetClientStreamServer interface { Spec() triple_protocol.Spec Peer() triple_protocol.Peer Recv() bool RequestHeader() http.Header Msg() *GreetClientStreamRequest Err() error Conn() triple_protocol.StreamingHandlerConn } type GreetServiceGreetClientStreamServer struct { *triple_protocol.ClientStream } func (srv *GreetServiceGreetClientStreamServer) Recv() bool { msg := new(GreetClientStreamRequest) return srv.ClientStream.Receive(msg) } func (srv *GreetServiceGreetClientStreamServer) Msg() *GreetClientStreamRequest { msgRaw := srv.ClientStream.Msg() if msgRaw == nil { return new(GreetClientStreamRequest) } return msgRaw.(*GreetClientStreamRequest) } type GreetService_GreetServerStreamServer interface { Send(*GreetServerStreamResponse) error ResponseHeader() http.Header ResponseTrailer() http.Header Conn() triple_protocol.StreamingHandlerConn } type GreetServiceGreetServerStreamServer struct { *triple_protocol.ServerStream } func (g *GreetServiceGreetServerStreamServer) Send(msg *GreetServerStreamResponse) error { return g.ServerStream.Send(msg) } var GreetService_ServiceInfo = server.ServiceInfo{ InterfaceName: "greet.GreetService", ServiceType: (*GreetServiceHandler)(nil), Methods: []server.MethodInfo{ { Name: "Greet", Type: constant.CallUnary, ReqInitFunc: func() interface{} { return new(GreetRequest) }, MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) { req := args[0].(*GreetRequest) res, err := handler.(GreetServiceHandler).Greet(ctx, req) if err != nil { return nil, err } return triple_protocol.NewResponse(res), nil }, }, { Name: "GreetStream", Type: constant.CallBidiStream, StreamInitFunc: func(baseStream interface{}) interface{} { return &GreetServiceGreetStreamServer{baseStream.(*triple_protocol.BidiStream)} }, MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) { stream := args[0].(GreetService_GreetStreamServer) if err := handler.(GreetServiceHandler).GreetStream(ctx, stream); err != nil { return nil, err } return nil, nil }, }, { Name: "GreetClientStream", Type: constant.CallClientStream, StreamInitFunc: func(baseStream interface{}) interface{} { return &GreetServiceGreetClientStreamServer{baseStream.(*triple_protocol.ClientStream)} }, MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) { stream := args[0].(GreetService_GreetClientStreamServer) res, err := handler.(GreetServiceHandler).GreetClientStream(ctx, stream) if err != nil { return nil, err } return triple_protocol.NewResponse(res), nil }, }, { Name: "GreetServerStream", Type: constant.CallServerStream, ReqInitFunc: func() interface{} { return new(GreetServerStreamRequest) }, StreamInitFunc: func(baseStream interface{}) interface{} { return &GreetServiceGreetServerStreamServer{baseStream.(*triple_protocol.ServerStream)} }, MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) { req := args[0].(*GreetServerStreamRequest) stream := args[1].(GreetService_GreetServerStreamServer) if err := handler.(GreetServiceHandler).GreetServerStream(ctx, req, stream); err != nil { return nil, err } return nil, nil }, }, }, }