// Code generated by protoc-gen-triple. DO NOT EDIT.
//
// Source: greet.proto
package greet

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 (
	// SentinelGreetServiceName is the fully-qualified name of the SentinelGreetService service.
	SentinelGreetServiceName = "greet.SentinelGreetService"
)

// 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 (
	// SentinelGreetServiceGreetProcedure is the fully-qualified name of the SentinelGreetService's Greet RPC.
	SentinelGreetServiceGreetProcedure = "/greet.SentinelGreetService/Greet"
	// SentinelGreetServiceGreetWithChanceOfErrorProcedure is the fully-qualified name of the SentinelGreetService's GreetWithChanceOfError RPC.
	SentinelGreetServiceGreetWithChanceOfErrorProcedure = "/greet.SentinelGreetService/GreetWithChanceOfError"
	// SentinelGreetServiceGreetWithQPSLimitProcedure is the fully-qualified name of the SentinelGreetService's GreetWithQPSLimit RPC.
	SentinelGreetServiceGreetWithQPSLimitProcedure = "/greet.SentinelGreetService/GreetWithQPSLimit"
	// SentinelGreetServiceGreetWithConcurrencyLimitProcedure is the fully-qualified name of the SentinelGreetService's GreetWithConcurrencyLimit RPC.
	SentinelGreetServiceGreetWithConcurrencyLimitProcedure = "/greet.SentinelGreetService/GreetWithConcurrencyLimit"
)

var (
	_ SentinelGreetService = (*SentinelGreetServiceImpl)(nil)
)

// SentinelGreetService is a client for the greet.SentinelGreetService service.
type SentinelGreetService interface {
	Greet(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error)
	GreetWithChanceOfError(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error)
	GreetWithQPSLimit(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error)
	GreetWithConcurrencyLimit(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error)
}

// NewSentinelGreetService constructs a client for the greet.SentinelGreetService service.
func NewSentinelGreetService(cli *client.Client, opts ...client.ReferenceOption) (SentinelGreetService, error) {
	conn, err := cli.DialWithInfo("greet.SentinelGreetService", &SentinelGreetService_ClientInfo, opts...)
	if err != nil {
		return nil, err
	}
	return &SentinelGreetServiceImpl{
		conn: conn,
	}, nil
}

func SetConsumerSentinelGreetService(srv common.RPCService) {
	dubbo.SetConsumerServiceWithInfo(srv, &SentinelGreetService_ClientInfo)
}

// SentinelGreetServiceImpl implements SentinelGreetService.
type SentinelGreetServiceImpl struct {
	conn *client.Connection
}

func (c *SentinelGreetServiceImpl) 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 *SentinelGreetServiceImpl) GreetWithChanceOfError(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error) {
	resp := new(GreetResponse)
	if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "GreetWithChanceOfError", opts...); err != nil {
		return nil, err
	}
	return resp, nil
}

func (c *SentinelGreetServiceImpl) GreetWithQPSLimit(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error) {
	resp := new(GreetResponse)
	if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "GreetWithQPSLimit", opts...); err != nil {
		return nil, err
	}
	return resp, nil
}

func (c *SentinelGreetServiceImpl) GreetWithConcurrencyLimit(ctx context.Context, req *GreetRequest, opts ...client.CallOption) (*GreetResponse, error) {
	resp := new(GreetResponse)
	if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "GreetWithConcurrencyLimit", opts...); err != nil {
		return nil, err
	}
	return resp, nil
}

var SentinelGreetService_ClientInfo = client.ClientInfo{
	InterfaceName: "greet.SentinelGreetService",
	MethodNames:   []string{"Greet", "GreetWithChanceOfError", "GreetWithQPSLimit", "GreetWithConcurrencyLimit"},
	ConnectionInjectFunc: func(dubboCliRaw interface{}, conn *client.Connection) {
		dubboCli := dubboCliRaw.(*SentinelGreetServiceImpl)
		dubboCli.conn = conn
	},
}

// SentinelGreetServiceHandler is an implementation of the greet.SentinelGreetService service.
type SentinelGreetServiceHandler interface {
	Greet(context.Context, *GreetRequest) (*GreetResponse, error)
	GreetWithChanceOfError(context.Context, *GreetRequest) (*GreetResponse, error)
	GreetWithQPSLimit(context.Context, *GreetRequest) (*GreetResponse, error)
	GreetWithConcurrencyLimit(context.Context, *GreetRequest) (*GreetResponse, error)
}

func RegisterSentinelGreetServiceHandler(srv *server.Server, hdlr SentinelGreetServiceHandler, opts ...server.ServiceOption) error {
	return srv.Register(hdlr, &SentinelGreetService_ServiceInfo, opts...)
}

func SetProviderSentinelGreetService(srv common.RPCService) {
	dubbo.SetProviderServiceWithInfo(srv, &SentinelGreetService_ServiceInfo)
}

var SentinelGreetService_ServiceInfo = server.ServiceInfo{
	InterfaceName: "greet.SentinelGreetService",
	ServiceType:   (*SentinelGreetServiceHandler)(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.(SentinelGreetServiceHandler).Greet(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "GreetWithChanceOfError",
			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.(SentinelGreetServiceHandler).GreetWithChanceOfError(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "GreetWithQPSLimit",
			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.(SentinelGreetServiceHandler).GreetWithQPSLimit(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "GreetWithConcurrencyLimit",
			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.(SentinelGreetServiceHandler).GreetWithConcurrencyLimit(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
	},
}
