func WithBackupRequest(p *retry.BackupPolicy) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		if p == nil {
			return
		}
		di.Push(fmt.Sprintf("WithBackupRequest(%+v)", *p))
		if o.RetryPolicy == nil {
			o.RetryPolicy = &retry.Policy{}
		}
		if o.RetryPolicy.FailurePolicy != nil {
			panic("Failure Retry has been setup, cannot support Backup Request at same time")
		}
		o.RetryPolicy.BackupPolicy = p
		o.RetryPolicy.Enable = true
		o.RetryPolicy.Type = retry.BackupType
	}}
}
WithBackupRequest sets the backup request policy for client.
package client
import (
	"context"
	"fmt"
	"net"
	"strings"
	"time"
	"github.com/cloudwego/kitex/internal/client"
	internal_stats "github.com/cloudwego/kitex/internal/stats"
	"github.com/cloudwego/kitex/pkg/circuitbreak"
	"github.com/cloudwego/kitex/pkg/connpool"
	"github.com/cloudwego/kitex/pkg/discovery"
	"github.com/cloudwego/kitex/pkg/endpoint"
	"github.com/cloudwego/kitex/pkg/http"
	"github.com/cloudwego/kitex/pkg/klog"
	"github.com/cloudwego/kitex/pkg/loadbalance"
	"github.com/cloudwego/kitex/pkg/loadbalance/lbcache"
	"github.com/cloudwego/kitex/pkg/remote"
	"github.com/cloudwego/kitex/pkg/remote/trans/netpollmux"
	"github.com/cloudwego/kitex/pkg/remote/trans/nphttp2"
	"github.com/cloudwego/kitex/pkg/retry"
	"github.com/cloudwego/kitex/pkg/rpcinfo"
	"github.com/cloudwego/kitex/pkg/stats"
	"github.com/cloudwego/kitex/pkg/utils"
	"github.com/cloudwego/kitex/transport"
)
type Option = client.Option
type Options = client.Options
type Suite interface {
	Options() []Option
}
func WithTransportProtocol(tp transport.Protocol) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		tpName := tp.String()
		if tpName == transport.Unknown {
			panic(fmt.Errorf("WithTransportProtocol: invalid '%v'", tp))
		}
		if tp == transport.GRPC {
			o.RemoteOpt.ConnPool = nphttp2.NewConnPool()
			o.RemoteOpt.CliHandlerFactory = nphttp2.NewCliTransHandlerFactory()
		}
		di.Push(fmt.Sprintf("WithTransportProtocol(%s)", tpName))
		rpcinfo.AsMutableRPCConfig(o.Configs).SetTransportProtocol(tp)
	}}
}
func WithSuite(suite Suite) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		var nested struct {
			Suite   string
			Options utils.Slice
		}
		nested.Suite = fmt.Sprintf("%T(%+v)", suite, suite)
		for _, op := range suite.Options() {
			op.F(o, &nested.Options)
		}
		di.Push(nested)
	}}
}
func WithMiddleware(mw endpoint.Middleware) Option {
	mwb := func(ctx context.Context) endpoint.Middleware {
		return mw
	}
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithMiddleware(%+v)", utils.GetFuncName(mw)))
		o.MWBs = append(o.MWBs, mwb)
	}}
}
func WithMiddlewareBuilder(mwb endpoint.MiddlewareBuilder) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithMiddlewareBuilder(%+v)", utils.GetFuncName(mwb)))
		o.MWBs = append(o.MWBs, mwb)
	}}
}
func WithInstanceMW(mw endpoint.Middleware) Option {
	imwb := func(ctx context.Context) endpoint.Middleware {
		return mw
	}
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithInstanceMW(%+v)", utils.GetFuncName(mw)))
		o.IMWBs = append(o.IMWBs, imwb)
	}}
}
func WithDestService(svr string) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		o.Once.OnceOrPanic()
		di.Push(fmt.Sprintf("WithDestService(%s)", svr))
		o.Svr.ServiceName = svr
	}}
}
func WithHostPorts(hostports ...string) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithHostPorts(%v)", hostports))
		var ins []discovery.Instance
		for _, hp := range hostports {
			if _, err := net.ResolveTCPAddr("tcp", hp); err == nil {
				ins = append(ins, discovery.NewInstance("tcp", hp, discovery.DefaultWeight, nil))
				continue
			}
			if _, err := net.ResolveUnixAddr("unix", hp); err == nil {
				ins = append(ins, discovery.NewInstance("unix", hp, discovery.DefaultWeight, nil))
				continue
			}
			panic(fmt.Errorf("WithHostPorts: invalid '%s'", hp))
		}
		if len(ins) == 0 {
			panic("WithHostPorts() requires at least one argument")
		}
		o.Targets = strings.Join(hostports, ",")
		o.Resolver = &discovery.SynthesizedResolver{
			ResolveFunc: func(ctx context.Context, key string) (discovery.Result, error) {
				return discovery.Result{
					Cacheable: true,
					CacheKey:  "fixed",
					Instances: ins,
				}, nil
			},
			NameFunc: func() string { return o.Targets },
		}
	}}
}
func WithResolver(r discovery.Resolver) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithResolver(%T)", r))
		o.Resolver = r
	}}
}
func WithHTTPResolver(r http.Resolver) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithHTTPResolver(%T)", r))
		o.HTTPResolver = r
	}}
}
func WithShortConnection() Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push("WithShortConnection")
		o.PoolCfg = new(connpool.IdleConfig)
	}}
}
func WithLongConnection(cfg connpool.IdleConfig) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithLongConnection(%+v)", cfg))
		o.PoolCfg = connpool.CheckPoolConfig(cfg)
	}}
}
func WithMuxConnection(connNum int) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push("WithMuxConnection")
		o.RemoteOpt.ConnPool = netpollmux.NewMuxConnPool(connNum)
		WithTransHandlerFactory(netpollmux.NewCliTransHandlerFactory()).F(o, di)
		rpcinfo.AsMutableRPCConfig(o.Configs).SetTransportProtocol(transport.TTHeader)
	}}
}
func WithLogger(logger klog.FormatLogger) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithLogger(%T)", logger))
		o.Logger = logger
	}}
}
func WithLoadBalancer(lb loadbalance.Loadbalancer, opts ...*lbcache.Options) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithLoadBalancer(%+v, %+v)", lb, opts))
		o.Balancer = lb
		if len(opts) > 0 {
			o.BalancerCacheOpt = opts[0]
		}
	}}
}
func WithRPCTimeout(d time.Duration) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithRPCTimeout(%dms)", d.Milliseconds()))
		rpcinfo.AsMutableRPCConfig(o.Configs).SetRPCTimeout(d)
		o.Locks.Bits |= rpcinfo.BitRPCTimeout
		o.CheckRPCTimeout = true
	}}
}
func WithConnectTimeout(d time.Duration) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithConnectTimeout(%dms)", d.Milliseconds()))
		rpcinfo.AsMutableRPCConfig(o.Configs).SetConnectTimeout(d)
		o.Locks.Bits |= rpcinfo.BitConnectTimeout
	}}
}
func WithTimeoutProvider(p rpcinfo.TimeoutProvider) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithTimeoutProvider(%T(%+v))", p, p))
		o.Timeouts = p
		o.CheckRPCTimeout = true
	}}
}
func WithTag(key, val string) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithTag(%s=%s)", key, val))
		o.Svr.Tags[key] = val
		o.Locks.Tags[key] = struct{}{}
	}}
}
func WithTracer(c stats.Tracer) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithTracer(%T{%+v})", c, c))
		if o.TracerCtl == nil {
			o.TracerCtl = &internal_stats.Controller{}
		}
		o.TracerCtl.Append(c)
	}}
}
func WithStatsLevel(level stats.Level) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithStatsLevel(%+v)", level))
		l := level
		o.StatsLevel = &l
	}}
}
func WithCodec(c remote.Codec) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithCodec(%+v)", c))
		o.RemoteOpt.Codec = c
	}}
}
func WithPayloadCodec(c remote.PayloadCodec) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithPayloadCodec(%+v)", c))
		o.RemoteOpt.PayloadCodec = c
	}}
}
func WithConnReporterEnabled() Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push("WithConnReporterEnabled()")
		o.RemoteOpt.EnableConnPoolReporter = true
	}}
}
func WithFailureRetry(p *retry.FailurePolicy) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		if p == nil {
			return
		}
		di.Push(fmt.Sprintf("WithFailureRetry(%+v)", *p))
		if o.RetryPolicy == nil {
			o.RetryPolicy = &retry.Policy{}
		}
		if o.RetryPolicy.BackupPolicy != nil {
			panic("BackupPolicy has been setup, cannot support Failure Retry at same time")
		}
		o.RetryPolicy.FailurePolicy = p
		o.RetryPolicy.Enable = true
		o.RetryPolicy.Type = retry.FailureType
	}}
}