func (p *BackOffPolicy) Equals(np *BackOffPolicy) bool {
	if p == nil {
		return np == nil
	}
	if np == nil {
		return false
	}
	if p.BackOffType != np.BackOffType {
		return false
	}
	if len(p.CfgItems) != len(np.CfgItems) {
		return false
	}
	for k := range p.CfgItems {
		if p.CfgItems[k] != np.CfgItems[k] {
			return false
		}
	}
	return true
}
Equals to check if BackOffPolicy is equal.
package retry
import (
	"fmt"
)
type Type int
const (
	FailureType Type = iota
	BackupType
)
func (t Type) String() string {
	switch t {
	case FailureType:
		return "Failure"
	case BackupType:
		return "Backup"
	}
	return ""
}
type Policy struct {
	Enable bool `json:"enable"`
	Type Type `json:"type"`
	FailurePolicy *FailurePolicy `json:"failure_policy,omitempty"`
	BackupPolicy  *BackupPolicy  `json:"backup_policy,omitempty"`
}
type FailurePolicy struct {
	StopPolicy    StopPolicy     `json:"stop_policy"`
	BackOffPolicy *BackOffPolicy `json:"backoff_policy,omitempty"`
	RetrySameNode bool           `json:"retry_same_node"`
}
type BackupPolicy struct {
	RetryDelayMS  uint32     `json:"retry_delay_ms"`
	StopPolicy    StopPolicy `json:"stop_policy"`
	RetrySameNode bool       `json:"retry_same_node"`
}
type StopPolicy struct {
	MaxRetryTimes    int      `json:"max_retry_times"`
	MaxDurationMS    uint32   `json:"max_duration_ms"`
	DisableChainStop bool     `json:"disable_chain_stop"`
	DDLStop          bool     `json:"ddl_stop"`
	CBPolicy         CBPolicy `json:"cb_policy"`
}
const defaultCBErrRate = 0.1
type CBPolicy struct {
	ErrorRate float64 `json:"error_rate"`
}
type BackOffPolicy struct {
	BackOffType BackOffType               `json:"backoff_type"`
	CfgItems    map[BackOffCfgKey]float64 `json:"cfg_items,omitempty"`
}
type BackOffType string
const (
	NoneBackOffType   BackOffType = "none"
	FixedBackOffType  BackOffType = "fixed"
	RandomBackOffType BackOffType = "random"
)
type BackOffCfgKey string
const (
	FixMSBackOffCfgKey      BackOffCfgKey = "fix_ms"
	MinMSBackOffCfgKey      BackOffCfgKey = "min_ms"
	MaxMSBackOffCfgKey      BackOffCfgKey = "max_ms"
	InitialMSBackOffCfgKey  BackOffCfgKey = "initial_ms"
	MultiplierBackOffCfgKey BackOffCfgKey = "multiplier"
)
func (p Policy) Equals(np Policy) bool {
	if p.Enable != np.Enable {
		return false
	}
	if p.Type != np.Type {
		return false
	}
	if !p.FailurePolicy.Equals(np.FailurePolicy) {
		return false
	}
	if !p.BackupPolicy.Equals(np.BackupPolicy) {
		return false
	}
	return true
}
func (p *FailurePolicy) Equals(np *FailurePolicy) bool {
	if p == nil {
		return np == nil
	}
	if np == nil {
		return false
	}
	if p.StopPolicy != np.StopPolicy {
		return false
	}
	if !p.BackOffPolicy.Equals(np.BackOffPolicy) {
		return false
	}
	if p.RetrySameNode != np.RetrySameNode {
		return false
	}
	return true
}
func (p *BackupPolicy) Equals(np *BackupPolicy) bool {
	if p == nil {
		return np == nil
	}
	if np == nil {
		return false
	}
	if p.RetryDelayMS != np.RetryDelayMS {
		return false
	}
	if p.StopPolicy != np.StopPolicy {
		return false
	}
	if p.RetrySameNode != np.RetrySameNode {
		return false
	}
	return true
}