Documentation ¶
Index ¶
- Constants
- func CheckRegion(region string) bool
- func GetBackendsSegment(strs []*loadbalance.Backend, cur, segmentLen int) []*loadbalance.Backend
- func GetClusterIDPostfix(clusterid string) string
- func NewClient(clbInfo *loadbalance.CloudLoadBalancer) (cloudlb.Interface, error)
- type CLBConfig
- type ClbClient
- func (clb *ClbClient) Add(ls *loadbalance.CloudListener) error
- func (clb *ClbClient) CreateLoadbalance() (*loadbalance.CloudLoadBalancer, error)
- func (clb *ClbClient) Delete(ls *loadbalance.CloudListener) error
- func (clb *ClbClient) DescribeLoadbalance(name string) (*loadbalance.CloudLoadBalancer, error)
- func (clb *ClbClient) ListListeners() ([]*loadbalance.CloudListener, error)
- func (clb *ClbClient) LoadConfig() error
- func (clb *ClbClient) Update(old, cur *loadbalance.CloudListener) error
Constants ¶
const ( // ConfigBcsClbRegion lb region from environment variable ConfigBcsClbRegion = "BCS_CLB_REGION" // ConfigBcsClbSecretID secret id from environment variable ConfigBcsClbSecretID = "BCS_CLB_SECRETID" // ConfigBcsClbSecretKey secret key from environment variable ConfigBcsClbSecretKey = "BCS_CLB_SECRETKEY" // ConfigBcsClbProjectID project id from environment variable ConfigBcsClbProjectID = "BCS_CLB_PROJECTID" // ConfigBcsClbCertID cert id from environment variable ConfigBcsClbCertID = "BCS_CLB_CERTID" // ConfigBcsClbVpcID vpc id from environment variable ConfigBcsClbVpcID = "BCS_CLB_VPCID" // ConfigBcsClbSubnet subnet from environment variable ConfigBcsClbSubnet = "BCS_CLB_SUBNET" // ConfigBcsClbSecurity security from environment variable ConfigBcsClbSecurity = "BCS_CLB_SECURITY" // ConfigBcsClbNetworkType networktype from environment variable ConfigBcsClbNetworkType = "BCS_CLB_NETWORKTYPE" // ConfigBcsClbBackendMode backend mode, CVM or ENI ConfigBcsClbBackendMode = "BCS_CLB_BACKENDMODE" ConfigBcsClbBackendModeCVM = "cvm" ConfigBcsClbBackendModeENI = "eni" // ConfigBcsClbCidrIP source cidr ip ConfigBcsClbCidrIP = "BCS_CLB_CIDRIP" // ConfigBcsClbExpireTime expire time ConfigBcsClbExpireTime = "BCS_CLB_EXPIRETIME" // DefaultClbCidrIP default clb cidr ip(默认开通科兴网段) DefaultClbCidrIP = "" // ConfigBcsClbMaxTimeout max retry times ConfigBcsClbMaxTimeout = "BCS_CLB_MAX_TIMEOUT" // DefaultClbMaxTimeout DefaultClbMaxTimeout = 180 // ConfigBcsClbWaitPeriodExceedLimit wait seconds for api exceed limit ConfigBcsClbWaitPeriodExceedLimit = "BCS_CLB_WAIT_PERIOD_EXCEED_LIMIT" // DefaultClbWaitPeriodExceedLimit default wait seconds for api exceed limit DefaultClbWaitPeriodExceedLimit = 10 // ConfigBcsClbWaitPeriodDealing wait secondes for lb busy ConfigBcsClbWaitPeriodDealing = "BCS_CLB_WAIT_PERIOD_DEALING" // DefaultClbWaitPeriodDealing default wait seconds for when lb is busy DefaultClbWaitPeriodDealing = 3 // ConfigBcsClbImplement clb implement type ConfigBcsClbImplement = "BCS_CLB_IMPLEMENT" // ConfigBcsClbImplementAPI use api ConfigBcsClbImplementAPI = "api" // ConfigBcsClbImplementSDK use official sdk ConfigBcsClbImplementSDK = "sdk" // LimitationMaxListenerNum clb limitation LimitationMaxListenerNum = 50 // LimitationMaxRulePerListener clb max rule for per listener LimitationMaxRulePerListener = 50 // LimitationMaxBackendNumPerRule max backend number for per rule LimitationMaxBackendNumPerRule = 100 // LimitationMaxBackendNumEachBind max backend number for each binding operation LimitationMaxBackendNumEachBind = 20 )
Parameters from environment variable
Variables ¶
This section is empty.
Functions ¶
func GetBackendsSegment ¶
func GetBackendsSegment(strs []*loadbalance.Backend, cur, segmentLen int) []*loadbalance.Backend
GetBackendsSegment get segment from a big string slice
func GetClusterIDPostfix ¶
GetClusterIDPostfix get postfix from cluster id
func NewClient ¶
func NewClient(clbInfo *loadbalance.CloudLoadBalancer) (cloudlb.Interface, error)
NewClient construct new clb client
Types ¶
type CLBConfig ¶
type CLBConfig struct { ImplementMode string `json:"implementmode"` BackendMode string `json:"backendmode"` Region string `json:"region"` SecretID string `json:"secretid"` SecretKey string `json:"secretkey"` ProjectID int `json:"projectid"` VpcID string `json:"vpcid"` CidrIP string `json:"cidrip"` ExpireTime int `json:"expire"` SubnetID string `json:"subnet"` Security []string `json:"security"` MaxTimeout int `json:"maxTimeout"` WaitPeriodExceedLimit int `json:"waitPeriodExceedLimit"` WaitPeriodLBDealing int `json:"waitPeriodDealing"` }
CLBConfig include all config of qcloud clb
func (*CLBConfig) GenerateSdkConfig ¶
GenerateSdkConfig generate sdk config
func (*CLBConfig) LoadFromEnv ¶
LoadFromEnv load clb config from env
func (*CLBConfig) ToJSONString ¶
ToJSONString to json string
type ClbClient ¶
type ClbClient struct {
// contains filtered or unexported fields
}
ClbClient client for operating clb
func (*ClbClient) Add ¶
func (clb *ClbClient) Add(ls *loadbalance.CloudListener) error
Add add cloud listener first check if any listener with the same port is existed, if existed, delete it
func (*ClbClient) CreateLoadbalance ¶
func (clb *ClbClient) CreateLoadbalance() (*loadbalance.CloudLoadBalancer, error)
CreateLoadbalance create lb, get lb id and vips
func (*ClbClient) Delete ¶
func (clb *ClbClient) Delete(ls *loadbalance.CloudListener) error
Delete delete listener if listener does not existed, do nothing
func (*ClbClient) DescribeLoadbalance ¶
func (clb *ClbClient) DescribeLoadbalance(name string) (*loadbalance.CloudLoadBalancer, error)
DescribeLoadbalance query lb by name
func (*ClbClient) ListListeners ¶
func (clb *ClbClient) ListListeners() ([]*loadbalance.CloudListener, error)
ListListeners list listener list listeners in current clb instance
func (*ClbClient) LoadConfig ¶
LoadConfig load clb config from env
func (*ClbClient) Update ¶
func (clb *ClbClient) Update(old, cur *loadbalance.CloudListener) error
Update update listener if listener does not existed, create one