package loadmodule

import "net/url"

type ProxyLoadType int

const (
	RandomProxyModule           ProxyLoadType = iota //随机
	RoundRobinProxyModule                            //轮询
	WeightRoundRobinProxyModule                      //权重
	//ConsistentHashProxy                            //哈希
)

type ProxyLoadModule interface {
	Add(string) error
	Get() *url.URL
	Len() int

	Update() //动态添加
}

func LoadProxyLoadFactory(value int) ProxyLoadModule {
	loadType := ProxyLoadType(value)
	switch loadType {
	case RandomProxyModule: //随机
		return &RandomProxy{}
	case RoundRobinProxyModule: //轮询
		return &RoundRobinProxy{}
	case WeightRoundRobinProxyModule: //权重
		return &WeightRoundRobinProxy{}
	//case ConsistentHashProxy: //哈希
	//	return NewConsistentHashBanlance(10, nil)
	default:
		return &RandomProxy{}
	}
}
