qcloud

package
v1.20.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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 CheckRegion

func CheckRegion(region string) bool

CheckRegion validate region field

func GetBackendsSegment

func GetBackendsSegment(strs []*loadbalance.Backend, cur, segmentLen int) []*loadbalance.Backend

GetBackendsSegment get segment from a big string slice

func GetClusterIDPostfix

func GetClusterIDPostfix(clusterid string) string

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 NewCLBCfg

func NewCLBCfg() *CLBConfig

NewCLBCfg return a clb cfg instance

func (*CLBConfig) GenerateSdkConfig

func (clbCfg *CLBConfig) GenerateSdkConfig() *sdk.Config

GenerateSdkConfig generate sdk config

func (*CLBConfig) LoadFromEnv

func (clbCfg *CLBConfig) LoadFromEnv() error

LoadFromEnv load clb config from env

func (*CLBConfig) ToJSONString

func (clbCfg *CLBConfig) ToJSONString() string

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

func (clb *ClbClient) LoadConfig() error

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

Directories

Path Synopsis
api
sdk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL