api

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//ClbPublic face internet
	ClbPublic = 2
	//ClbPrivate face internal network
	ClbPrivate = 3
	//ClbApplicationType application type lb
	ClbApplicationType = 1
	//ClbTraditionalType traditional type lb (never used)
	ClbTraditionalType = 0

	//ClbListenerProtocolHTTP clb listener http protocol
	ClbListenerProtocolHTTP = 1
	//ClbListenerProtocolHTTPS clb listener https protocol
	ClbListenerProtocolHTTPS = 4
	//ClbListenerProtocolTCP clb listener tcp protocol
	ClbListenerProtocolTCP = 2
	//ClbListenerProtocolUDP clb listener udp protocol
	ClbListenerProtocolUDP = 3

	//ClbInstanceRunningStatus clb instance running normally
	ClbInstanceRunningStatus = 1
	//ClbInstanceCreatingStatus clb instance is under creating
	ClbInstanceCreatingStatus = 0

	//ClbSecurityGroupDefaultFromPort clb security group default begin port
	ClbSecurityGroupDefaultFromPort = 31000
	//ClbSecurityGroupDefaultEndPort clb security group default end port
	ClbSecurityGroupDefaultEndPort = 32000

	//ClbConfigPath clb config file path
	ClbConfigPath = "conf/clbConf/clbConfig.conf"

	//ClbSecurityGroupPolicyIndex 修改安全组的第0条规则
	ClbSecurityGroupPolicyIndex = 0
	//ClbVIPSgPolicyIndex 对VIP开放的安全策略位置,在第一条规则上创建,排在端口策略后面
	ClbVIPSgPolicyIndex = 1

	//LBAlgorithmIPHash IP Hash
	LBAlgorithmIPHash = "ip_hash"
	//LBAlgorithmLeastConn least conn
	LBAlgorithmLeastConn = "least_conn"
	//LBAlgorithmRoundRobin round robin
	LBAlgorithmRoundRobin = "wrr"

	// HealthSwitchOn 开启健康检查
	HealthSwitchOn = 1
	// HealthSwitchOff 关闭健康检查
	HealthSwitchOff = 0

	// SecurityGroupPolicyProtocolUDP security policy for udp
	SecurityGroupPolicyProtocolUDP = "udp"
	// SecurityGroupPolicyProtocolTCP security policy for tcp
	SecurityGroupPolicyProtocolTCP = "tcp"

	// TaskResultStatusSuccess result status for success
	TaskResultStatusSuccess = 0
	// TaskResultStatusFailed result status for failed
	TaskResultStatusFailed = 1
	// TaskResultStatusDealing result status for dealing
	TaskResultStatusDealing = 2

	// QCloudLBURL tencent cloud lb url
	QCloudLBURL = "https://lb.api.qcloud.com/v2/index.php"
	// QCloudCVMURL tencent cloud cvm v2 url
	QCloudCVMURL = "https://cvm.api.qcloud.com/v2/index.php"
	// QCloudCVMURLV3 tencent cloud cvm v3 url
	QCloudCVMURLV3 = "https://cvm.tencentcloudapi.com/"
	// QCloudDfwURL tencent cloud dfw url
	QCloudDfwURL = "https://dfw.api.qcloud.com/v2/index.php"

	//ClbMaxTimeout 异步clb接口超时时间,之所以定三分钟是因为之前遇到过最久的接口是一分多钟
	ClbMaxTimeout = 180

	// RequestLimitExceededCode code for request exceeded limit
	RequestLimitExceededCode = 4400
	// RequestLimitExceededMessage message for request exceeded limit
	RequestLimitExceededMessage = "RequestLimitExceeded"
	// WrongStatusCode code for incorrect status
	WrongStatusCode = 4000
	// WrongStatusMessage message for incorrect status
	WrongStatusMessage = "IncorrectStatus.LBWrongStatus"
)

Variables

View Source
var (
	// LBAlgorithmTypeBcs2QCloudMap map for algorithm name mapping from bcs to qcloud
	LBAlgorithmTypeBcs2QCloudMap = map[string]string{
		loadbalance.ClbLBPolicyLeastConn: LBAlgorithmLeastConn,
		loadbalance.ClbLBPolicyWRR:       LBAlgorithmRoundRobin,
		loadbalance.ClbLBPolicyIPHash:    LBAlgorithmIPHash,
	}
	// LBAlgorithmTypeQCloud2BcsMap map for algorithm name mapping from qcloud to bcs
	LBAlgorithmTypeQCloud2BcsMap = map[string]string{
		LBAlgorithmLeastConn:  loadbalance.ClbLBPolicyLeastConn,
		LBAlgorithmRoundRobin: loadbalance.ClbLBPolicyWRR,
		LBAlgorithmIPHash:     loadbalance.ClbLBPolicyIPHash,
	}
	// NetworkTypeBcs2QCloudMap map for network type from bcs to qcloud
	NetworkTypeBcs2QCloudMap = map[string]int{
		loadbalance.ClbNetworkTypePrivate: ClbPrivate,
		loadbalance.ClbNetworkTypePublic:  ClbPublic,
	}
	// NetworkTypeQCloud2BcsMap map for network type from qcloud to bcs
	NetworkTypeQCloud2BcsMap = map[int]string{
		ClbPrivate: loadbalance.ClbNetworkTypePrivate,
		ClbPublic:  loadbalance.ClbNetworkTypePublic,
	}
	// ProtocolTypeBcs2QCloudMap map for protocol type from bcs to qcloud
	ProtocolTypeBcs2QCloudMap = map[string]int{
		loadbalance.ClbListenerProtocolHTTP:  ClbListenerProtocolHTTP,
		loadbalance.ClbListenerProtocolHTTPS: ClbListenerProtocolHTTPS,
		loadbalance.ClbListenerProtocolTCP:   ClbListenerProtocolTCP,
		loadbalance.ClbListenerProtocolUDP:   ClbListenerProtocolUDP,
	}
	// ProtocolTypeQCloud2BcsMap map for protocol type from qcloud to bcs
	ProtocolTypeQCloud2BcsMap = map[int]string{
		ClbListenerProtocolHTTP:  loadbalance.ClbListenerProtocolHTTP,
		ClbListenerProtocolHTTPS: loadbalance.ClbListenerProtocolHTTPS,
		ClbListenerProtocolTCP:   loadbalance.ClbListenerProtocolTCP,
		ClbListenerProtocolUDP:   loadbalance.ClbListenerProtocolUDP,
	}
)

Functions

func NewCloudClbAPI

func NewCloudClbAPI(projectID int, region, subnet, vpcID, secretID, secretKey, backendType string,
	waitPeriodLBDealing, waitPeriodExceedLimit, expireTime int) qcloudif.ClbAdapter

NewCloudClbAPI new clb api operator

Types

type ClbAPI

type ClbAPI struct {

	// project id for tencent cloud account
	ProjectID int
	// region for clb
	Region string
	// subnet id for private clb instance
	SubnetID string
	// vpc id for clb instance
	VpcID string
	// secret id for tencent cloud account
	SecretID string
	// secret key for tencent cloud account
	SecretKey string
	// backend type: CVM or eni
	BackendType string
	// wait second for next query when task is dealing
	WaitPeriodLBDealing int
	// wait second for next query when exceeding api limit
	WaitPeriodExceedLimit    int
	ExpireTimeForHTTPSession int
	// contains filtered or unexported fields
}

ClbAPI Clb api operator

func (*ClbAPI) CreateListener

func (clb *ClbAPI) CreateListener(listener *loadbalance.CloudListener) (string, error)

CreateListener create listener

func (*ClbAPI) CreateLoadBalance

func (clb *ClbAPI) CreateLoadBalance(lb *loadbalance.CloudLoadBalancer) (string, []string, error)

CreateLoadBalance create clb by incoming cloud loadbalance info return clb instance id, vips and err

func (*ClbAPI) CreateRules

func (clb *ClbAPI) CreateRules(lbID, listenerID string, rules loadbalance.RuleList) error

CreateRules create rules

func (*ClbAPI) DeRegister4LayerBackends

func (clb *ClbAPI) DeRegister4LayerBackends(lbID, listenerID string, backendsDeRegister loadbalance.BackendList) error

DeRegister4LayerBackends de register backends for 4 layer deprecated

func (*ClbAPI) DeRegister7LayerBackends

func (clb *ClbAPI) DeRegister7LayerBackends(
	lbID, listenerID, ruleID string, backendsDeRegister loadbalance.BackendList) error

DeRegister7LayerBackends de register backends for 7 layer

func (*ClbAPI) DeleteListener

func (clb *ClbAPI) DeleteListener(lbID, listenerID string) error

DeleteListener delete listener

func (*ClbAPI) DeleteRule

func (clb *ClbAPI) DeleteRule(lbID, listenerID, domain, url string) error

DeleteRule delete rule by domain and url

func (*ClbAPI) DescribeListener

func (clb *ClbAPI) DescribeListener(lbID, listenerID string, port int) (*loadbalance.CloudListener, bool, error)

DescribeListener describe listener response does not contains backends info

func (*ClbAPI) DescribeLoadBalance

func (clb *ClbAPI) DescribeLoadBalance(name string) (*loadbalance.CloudLoadBalancer, bool, error)

DescribeLoadBalance describe clb by name

func (*ClbAPI) DescribeRuleByDomainAndURL

func (clb *ClbAPI) DescribeRuleByDomainAndURL(loadBalanceID, listenerID, Domain, URL string) (
	*loadbalance.Rule, bool, error)

DescribeRuleByDomainAndURL query rule by domain and url

func (*ClbAPI) ListListener

func (clb *ClbAPI) ListListener(lbID string) ([]*loadbalance.CloudListener, error)

ListListener list all listeners

func (*ClbAPI) ModifyListenerAttribute

func (clb *ClbAPI) ModifyListenerAttribute(listener *loadbalance.CloudListener) error

ModifyListenerAttribute modify listener attribute

func (*ClbAPI) ModifyRuleAttribute

func (clb *ClbAPI) ModifyRuleAttribute(loadBalanceID, listenerID string, rule *loadbalance.Rule) error

ModifyRuleAttribute modify rule attribute

func (*ClbAPI) Register4LayerBackends

func (clb *ClbAPI) Register4LayerBackends(lbID, listenerID string, backendsRegister loadbalance.BackendList) error

Register4LayerBackends register 4 layer backends

func (*ClbAPI) Register7LayerBackends

func (clb *ClbAPI) Register7LayerBackends(
	lbID, listenerID, ruleID string, backendsRegister loadbalance.BackendList) error

Register7LayerBackends register 7 layer backends

Jump to

Keyboard shortcuts

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