// Code generated by protoc-gen-triple. DO NOT EDIT.
//
// Source: seata.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 (
	// UserProviderName is the fully-qualified name of the UserProvider service.
	UserProviderName = "service.UserProvider"
)

// 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 (
	// UserProviderPrepareProxyProcedure is the fully-qualified name of the UserProvider's PrepareProxy RPC.
	UserProviderPrepareProxyProcedure = "/service.UserProvider/PrepareProxy"
	// UserProviderCommitProxyProcedure is the fully-qualified name of the UserProvider's CommitProxy RPC.
	UserProviderCommitProxyProcedure = "/service.UserProvider/CommitProxy"
	// UserProviderRollbackProxyProcedure is the fully-qualified name of the UserProvider's RollbackProxy RPC.
	UserProviderRollbackProxyProcedure = "/service.UserProvider/RollbackProxy"
	// UserProviderGetActionNameProxyProcedure is the fully-qualified name of the UserProvider's GetActionNameProxy RPC.
	UserProviderGetActionNameProxyProcedure = "/service.UserProvider/GetActionNameProxy"
)

var (
	_ UserProvider = (*UserProviderImpl)(nil)
)

// UserProvider is a client for the service.UserProvider service.
type UserProvider interface {
	PrepareProxy(ctx context.Context, req *PrepareRequest, opts ...client.CallOption) (*PrepareResponse, error)
	CommitProxy(ctx context.Context, req *CommitRequest, opts ...client.CallOption) (*CommitResponse, error)
	RollbackProxy(ctx context.Context, req *RollbackRequest, opts ...client.CallOption) (*RollbackResponse, error)
	GetActionNameProxy(ctx context.Context, req *GetActionNameRequest, opts ...client.CallOption) (*GetActionNameResponse, error)
}

// NewUserProvider constructs a client for the proto.UserProvider service.
func NewUserProvider(cli *client.Client, opts ...client.ReferenceOption) (UserProvider, error) {
	conn, err := cli.DialWithInfo("service.UserProvider", &UserProvider_ClientInfo, opts...)
	if err != nil {
		return nil, err
	}
	return &UserProviderImpl{
		conn: conn,
	}, nil
}

func SetConsumerUserProvider(srv common.RPCService) {
	dubbo.SetConsumerServiceWithInfo(srv, &UserProvider_ClientInfo)
}

// UserProviderImpl implements UserProvider.
type UserProviderImpl struct {
	conn *client.Connection
}

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

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

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

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

var UserProvider_ClientInfo = client.ClientInfo{
	InterfaceName: "service.UserProvider",
	MethodNames:   []string{"PrepareProxy", "CommitProxy", "RollbackProxy", "GetActionNameProxy"},
	ConnectionInjectFunc: func(dubboCliRaw interface{}, conn *client.Connection) {
		dubboCli := dubboCliRaw.(*UserProviderImpl)
		dubboCli.conn = conn
	},
}

// UserProviderHandler is an implementation of the service.UserProvider service.
type UserProviderHandler interface {
	PrepareProxy(context.Context, *PrepareRequest) (*PrepareResponse, error)
	CommitProxy(context.Context, *CommitRequest) (*CommitResponse, error)
	RollbackProxy(context.Context, *RollbackRequest) (*RollbackResponse, error)
	GetActionNameProxy(context.Context, *GetActionNameRequest) (*GetActionNameResponse, error)
}

func RegisterUserProviderHandler(srv *server.Server, hdlr UserProviderHandler, opts ...server.ServiceOption) error {
	return srv.Register(hdlr, &UserProvider_ServiceInfo, opts...)
}

func SetProviderUserProvider(srv common.RPCService) {
	dubbo.SetProviderServiceWithInfo(srv, &UserProvider_ServiceInfo)
}

var UserProvider_ServiceInfo = server.ServiceInfo{
	InterfaceName: "service.UserProvider",
	ServiceType:   (*UserProviderHandler)(nil),
	Methods: []server.MethodInfo{
		{
			Name: "PrepareProxy",
			Type: constant.CallUnary,
			ReqInitFunc: func() interface{} {
				return new(PrepareRequest)
			},
			MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
				req := args[0].(*PrepareRequest)
				res, err := handler.(UserProviderHandler).PrepareProxy(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "CommitProxy",
			Type: constant.CallUnary,
			ReqInitFunc: func() interface{} {
				return new(CommitRequest)
			},
			MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
				req := args[0].(*CommitRequest)
				res, err := handler.(UserProviderHandler).CommitProxy(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "RollbackProxy",
			Type: constant.CallUnary,
			ReqInitFunc: func() interface{} {
				return new(RollbackRequest)
			},
			MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
				req := args[0].(*RollbackRequest)
				res, err := handler.(UserProviderHandler).RollbackProxy(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "GetActionNameProxy",
			Type: constant.CallUnary,
			ReqInitFunc: func() interface{} {
				return new(GetActionNameRequest)
			},
			MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
				req := args[0].(*GetActionNameRequest)
				res, err := handler.(UserProviderHandler).GetActionNameProxy(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
	},
}
