blob: 531c430ab653298d6812519cddb93d761dc4c8b2 [file] [log] [blame]
// Code generated by protoc-gen-triple. DO NOT EDIT.
//
// Source: greet.proto
package proto
import (
"context"
)
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 (
// GreeterName is the fully-qualified name of the Greeter service.
GreeterName = "org.apache.dubbo.samples.Greeter"
)
// 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 (
// GreeterSayHelloProcedure is the fully-qualified name of the Greeter's SayHello RPC.
GreeterSayHelloProcedure = "/org.apache.dubbo.samples.Greeter/SayHello"
)
var (
_ Greeter = (*GreeterImpl)(nil)
)
// Greeter is a client for the org.apache.dubbo.samples.Greeter service.
type Greeter interface {
SayHello(ctx context.Context, req *HelloRequest, opts ...client.CallOption) (*HelloReply, error)
}
// NewGreeter constructs a client for the proto.Greeter service.
func NewGreeter(cli *client.Client, opts ...client.ReferenceOption) (Greeter, error) {
conn, err := cli.DialWithInfo("org.apache.dubbo.samples.Greeter", &Greeter_ClientInfo, opts...)
if err != nil {
return nil, err
}
return &GreeterImpl{
conn: conn,
}, nil
}
func SetConsumerService(srv common.RPCService) {
dubbo.SetConsumerServiceWithInfo(srv, &Greeter_ClientInfo)
}
// GreeterImpl implements Greeter.
type GreeterImpl struct {
conn *client.Connection
}
func (c *GreeterImpl) SayHello(ctx context.Context, req *HelloRequest, opts ...client.CallOption) (*HelloReply, error) {
resp := new(HelloReply)
if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "SayHello", opts...); err != nil {
return nil, err
}
return resp, nil
}
var Greeter_ClientInfo = client.ClientInfo{
InterfaceName: "org.apache.dubbo.samples.Greeter",
MethodNames: []string{"SayHello"},
ConnectionInjectFunc: func(dubboCliRaw interface{}, conn *client.Connection) {
dubboCli := dubboCliRaw.(*GreeterImpl)
dubboCli.conn = conn
},
}
// GreeterHandler is an implementation of the org.apache.dubbo.samples.Greeter service.
type GreeterHandler interface {
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
}
func RegisterGreeterHandler(srv *server.Server, hdlr GreeterHandler, opts ...server.ServiceOption) error {
return srv.Register(hdlr, &Greeter_ServiceInfo, opts...)
}
func SetProviderService(srv common.RPCService) {
dubbo.SetProviderServiceWithInfo(srv, &Greeter_ServiceInfo)
}
var Greeter_ServiceInfo = server.ServiceInfo{
InterfaceName: "org.apache.dubbo.samples.Greeter",
ServiceType: (*GreeterHandler)(nil),
Methods: []server.MethodInfo{
{
Name: "SayHello",
Type: constant.CallUnary,
ReqInitFunc: func() interface{} {
return new(HelloRequest)
},
MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
req := args[0].(*HelloRequest)
res, err := handler.(GreeterHandler).SayHello(ctx, req)
if err != nil {
return nil, err
}
return triple_protocol.NewResponse(res), nil
},
},
},
}