icluster_conf

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigTopicClusterTable = "cluster_table"
	ConfigTopicGSLB         = "gslb"
)
View Source
const BlackHole = "GSLB_BLACKHOLE"
View Source
const (
	ResourceClusterRule = "cluster_rule"
)

Variables

View Source
var (
	ClusterHashStrategyClientIDOnlyI     int32 = 0
	ClusterHashStrategyClientIPOnlyI     int32 = 1
	ClusterHashStrategyClientIDPreferedI int32 = 2

	ClusterHealthCheckHTTP      = "http"
	ClusterHealthCheckTCP       = "tcp"
	ClusterHealthCheckSchemaMap = map[string]bool{
		ClusterHealthCheckHTTP: true,
		ClusterHealthCheckTCP:  true,
	}

	ClusterStickTypeSubCluster = "SUB_CLUSTER"
	ClusterStickTypeInstance   = "INSTANCE"

	ClusterDefaultReqFlushInterval int32 = 0
	ClusterDefaultResFlushInterval int32 = -1 // -1: write response directly without using timing refresh
)
View Source
var (
	UnMountedClusterID int64 = -1

	RouteAdvancedModeClusterName4DP       = route_rule_conf.AdvancedMode
	RouteAdvancedModeClusterName          = "GO_TO_ADVANCED_RULES"
	RouteAdvancedModeClusterID      int64 = -1

	SystemKeepRouteNames = map[string]bool{
		RouteAdvancedModeClusterName:    true,
		RouteAdvancedModeClusterName4DP: true,
	}
)
View Source
var (
	PoolTagBFE     int8 = 1
	PoolTagProduct int8 = 2
)

Functions

func ClusterList2MapByID

func ClusterList2MapByID(list []*Cluster) map[int64]*Cluster

func ClusterList2MapByName

func ClusterList2MapByName(list []*Cluster) map[string]*Cluster

func NewBfeClusterConf

func NewBfeClusterConf(version string, clusters []*Cluster) *cluster_conf.BfeClusterConf

func PoolList2Map

func PoolList2Map(list []*Pool) map[int64]*Pool

func SubClusterList2IDSlice

func SubClusterList2IDSlice(list []*SubCluster) []int64

func SubClusterList2MapByID

func SubClusterList2MapByID(list []*SubCluster) map[int64]*SubCluster

func SubClusterList2MapByName

func SubClusterList2MapByName(list []*SubCluster) map[string]*SubCluster

func SubClusterList2NameSlice

func SubClusterList2NameSlice(list []*SubCluster) []string

Types

type Cluster

type Cluster struct {
	ID          int64
	Name        string
	Description string
	Ready       bool
	ProductID   int64

	Basic              *ClusterBasic
	StickySessions     *ClusterStickySessions
	SubClusters        []*SubCluster
	Scheduler          map[string]map[string]int
	PassiveHealthCheck *ClusterPassiveHealthCheck
}

func AppendAdvancedRuleCluster

func AppendAdvancedRuleCluster(list []*Cluster) []*Cluster

func (*Cluster) SubClusterNames

func (cluster *Cluster) SubClusterNames() []string

type ClusterBasic

type ClusterBasic struct {
	Connection *ClusterBasicConnection
	Retries    *ClusterBasicRetries
	Buffers    *ClusterBasicBuffers
	Timeouts   *ClusterBasicTimeouts
}

type ClusterBasicBuffers

type ClusterBasicBuffers struct {
	ReqWriteBufferSize int32
	ReqFlushInterval   int32
	ResFlushInterval   int32
}

type ClusterBasicBuffersParam

type ClusterBasicBuffersParam struct {
	ReqWriteBufferSize *int32
	ReqFlushInterval   *int32
	ResFlushInterval   *int32
}

type ClusterBasicConnection

type ClusterBasicConnection struct {
	MaxIdleConnPerRs    int16
	CancelOnClientClose bool
}

type ClusterBasicConnectionParam

type ClusterBasicConnectionParam struct {
	MaxIdleConnPerRs    *int16
	CancelOnClientClose *bool
}

type ClusterBasicParam

type ClusterBasicParam struct {
	Connection *ClusterBasicConnectionParam
	Retries    *ClusterBasicRetriesParam
	Buffers    *ClusterBasicBuffersParam
	Timeouts   *ClusterBasicTimeoutsParam
}

type ClusterBasicRetries

type ClusterBasicRetries struct {
	MaxRetryInSubcluster    int8
	MaxRetryCrossSubcluster int8
}

type ClusterBasicRetriesParam

type ClusterBasicRetriesParam struct {
	MaxRetryInSubcluster    *int8
	MaxRetryCrossSubcluster *int8
}

type ClusterBasicTimeouts

type ClusterBasicTimeouts struct {
	TimeoutConnServ        int32
	TimeoutResponseHeader  int32
	TimeoutReadbodyClient  int32
	TimeoutReadClientAgain int32
	TimeoutWriteClient     int32
}

type ClusterBasicTimeoutsParam

type ClusterBasicTimeoutsParam struct {
	TimeoutConnServ        *int32
	TimeoutResponseHeader  *int32
	TimeoutReadbodyClient  *int32
	TimeoutReadClientAgain *int32
	TimeoutWriteClient     *int32
}

type ClusterFilter

type ClusterFilter struct {
	ID  *int64
	IDs []int64

	Names []string
	Name  *string

	Product *ibasic.Product
}

type ClusterManager

type ClusterManager struct {
	// contains filtered or unexported fields
}

func NewClusterManager

func NewClusterManager(txn itxn.TxnStorager, storager ClusterStorager,
	subClusterStorager SubClusterStorager, bfeClusterStorager ibasic.BFEClusterStorager,
	versionControlManager *iversion_control.VersionControlManager,
	deleteCheckers map[string]func(context.Context, *ibasic.Product, *Cluster) error) *ClusterManager

func (*ClusterManager) CreateCluster

func (cm *ClusterManager) CreateCluster(ctx context.Context, product *ibasic.Product, param *ClusterParam) (err error)

func (*ClusterManager) DeleteCluster

func (cm *ClusterManager) DeleteCluster(ctx context.Context, product *ibasic.Product, cluster *Cluster) (err error)

func (*ClusterManager) ExportClusterTable

func (rm *ClusterManager) ExportClusterTable(ctx context.Context, lastVersion string) (*ClusterTableConf, error)

func (*ClusterManager) ExportGSLB

func (rm *ClusterManager) ExportGSLB(ctx context.Context, lastVersion, bfeClusterName string) (*GSLBConf, error)

func (*ClusterManager) FetchCluster

func (cm *ClusterManager) FetchCluster(ctx context.Context, param *ClusterFilter) (*Cluster, error)

func (*ClusterManager) FetchClusterList

func (rm *ClusterManager) FetchClusterList(ctx context.Context, param *ClusterFilter) (list []*Cluster, err error)

func (*ClusterManager) RebindSubCluster

func (cm *ClusterManager) RebindSubCluster(ctx context.Context, product *ibasic.Product, cluster *Cluster,
	bindingSubClusterNames []string) error

func (*ClusterManager) UpdateCluster

func (cm *ClusterManager) UpdateCluster(ctx context.Context, product *ibasic.Product, oldData *Cluster,
	param *ClusterParam) (err error)

type ClusterParam

type ClusterParam struct {
	ID *int64

	Name *string

	ProductID *int64

	Description *string

	Basic *ClusterBasicParam

	StickySessions *ClusterStickySessionsParam

	SubClusters []string

	Scheduler map[string]map[string]int

	PassiveHealthCheck *ClusterPassiveHealthCheckParam
}

type ClusterPassiveHealthCheck

type ClusterPassiveHealthCheck struct {
	Schema     string
	Interval   int32
	Failnum    int32
	Statuscode int32
	Host       string
	Uri        string
}

type ClusterPassiveHealthCheckParam

type ClusterPassiveHealthCheckParam struct {
	Schema     *string
	Interval   *int32
	Failnum    *int32
	Statuscode *int32
	Host       *string
	Uri        *string
}

type ClusterStickySessions

type ClusterStickySessions struct {
	SessionSticky bool
	HashStrategy  int32
	HashHeader    string
}

type ClusterStickySessionsParam

type ClusterStickySessionsParam struct {
	SessionSticky *bool
	HashStrategy  *int32
	HashHeader    *string
}

type ClusterStorager

type ClusterStorager interface {
	FetchCluster(ctx context.Context, param *ClusterFilter) (*Cluster, error)
	FetchClusterList(ctx context.Context, param *ClusterFilter) ([]*Cluster, error)
	ClusterUpdate(ctx context.Context, product *ibasic.Product, old *Cluster, param *ClusterParam) error
	ClusterCreate(ctx context.Context, product *ibasic.Product, param *ClusterParam, subClusters []*SubCluster) (int64, error)
	ClusterDelete(ctx context.Context, product *ibasic.Product, cluster *Cluster) error
	BindSubCluster(ctx context.Context, cluster *Cluster, appendSubClusters, unbindSubClusters []*SubCluster) error
}

type ClusterTableConf

type ClusterTableConf struct {
	cluster_table_conf.ClusterTableConf
}

func (*ClusterTableConf) UpdateVersion

func (ctc *ClusterTableConf) UpdateVersion(version string) error

type GSLBConf

type GSLBConf struct {
	Version string
	gslb_conf.GslbConf
}

func (*GSLBConf) UpdateVersion

func (gc *GSLBConf) UpdateVersion(version string) error

type Instance

type Instance struct {
	HostName string            `json:"Name"`
	IP       string            `json:"Addr"`
	Port     int               `json:"Port"`
	Ports    map[string]int    `json:"Ports,omitempty"`
	Tags     map[string]string `json:"tags,omitempty"`
	Weight   int64             `json:"Weight"`
	Disable  bool              `json:"Disable"`
}

func (*Instance) IPWithPort

func (i *Instance) IPWithPort() string

type Pool

type Pool struct {
	ID        int64
	Name      string
	Ready     bool
	Product   *ibasic.Product
	Instances []Instance
	Tag       int8
}

type PoolFilter

type PoolFilter struct {
	Name      *string
	IDs       []int64
	ID        *int64
	ProductID *int64
}

type PoolManager

type PoolManager struct {
	// contains filtered or unexported fields
}

func NewPoolManager

func NewPoolManager(txn itxn.TxnStorager, storager PoolStorager,
	bfeClusterStorager ibasic.BFEClusterStorager, subClusterStorager SubClusterStorager) *PoolManager

func (*PoolManager) CanDelete

func (rppm *PoolManager) CanDelete(ctx context.Context, pool *Pool) error

CanDelete check whether pool can be deleted, Check Logic: 1. Not BFE Cluster Refer To 2. Not SubCluster Refer To

func (*PoolManager) CreateBFEPool

func (rppm *PoolManager) CreateBFEPool(ctx context.Context, pool *PoolParam) (one *Pool, err error)

func (*PoolManager) CreateProductPool

func (rppm *PoolManager) CreateProductPool(ctx context.Context, product *ibasic.Product, pool *PoolParam) (one *Pool, err error)

func (*PoolManager) DeleteBFEPool

func (rppm *PoolManager) DeleteBFEPool(ctx context.Context, name string) (one *Pool, err error)

func (*PoolManager) DeleteProductPool

func (rppm *PoolManager) DeleteProductPool(ctx context.Context, product *ibasic.Product, name string) (one *Pool, err error)

func (*PoolManager) FetchBFEPool

func (rppm *PoolManager) FetchBFEPool(ctx context.Context, name string) (one *Pool, err error)

func (*PoolManager) FetchBFEPools

func (rppm *PoolManager) FetchBFEPools(ctx context.Context) (list []*Pool, err error)

func (*PoolManager) FetchPoolByName

func (rppm *PoolManager) FetchPoolByName(ctx context.Context, name string) (one *Pool, err error)

func (*PoolManager) FetchProductPool

func (rppm *PoolManager) FetchProductPool(ctx context.Context, product *ibasic.Product, name string) (one *Pool, err error)

func (*PoolManager) FetchProductPools

func (rppm *PoolManager) FetchProductPools(ctx context.Context, product *ibasic.Product) (list []*Pool, err error)

func (*PoolManager) GetPoolByName

func (rppm *PoolManager) GetPoolByName(ctx context.Context, poolName *string) (pool *Pool, err error)

func (*PoolManager) UpdateBFEPool

func (rppm *PoolManager) UpdateBFEPool(ctx context.Context, pool *Pool, diff *PoolParam) (err error)

func (*PoolManager) UpdateProductPool

func (rppm *PoolManager) UpdateProductPool(ctx context.Context, product *ibasic.Product, pool *Pool, diff *PoolParam) (err error)

type PoolParam

type PoolParam struct {
	ID        *int64
	Name      *string
	ProductID *int64
	Instances []Instance

	Tag *int8
}

type PoolStorager

type PoolStorager interface {
	FetchPool(ctx context.Context, name string) (*Pool, error)
	FetchPools(ctx context.Context, param *PoolFilter) ([]*Pool, error)

	CreatePool(ctx context.Context, product *ibasic.Product, data *PoolParam) (*Pool, error)
	UpdatePool(ctx context.Context, oldData *Pool, diff *PoolParam) error
	DeletePool(ctx context.Context, pool *Pool) error
}

type SubCluster

type SubCluster struct {
	ID   int64
	Name string

	ClusterID int64

	ProductID   int64
	ProductName string

	InstancePool *Pool

	Capacity    int64
	Enabled     bool
	Ready       bool
	Description string
}

type SubClusterFilter

type SubClusterFilter struct {
	ID    *int64
	Name  *string
	Names []string

	InstancePool *Pool
	PoolIDs      []int64

	Product *ibasic.Product

	ClusterIDs []int64
}

type SubClusterManager

type SubClusterManager struct {
	// contains filtered or unexported fields
}

func NewSubClusterManager

func NewSubClusterManager(txn itxn.TxnStorager, storager SubClusterStorager,
	productStorager ibasic.ProductStorager, poolStorager PoolStorager,
	clusterStorager ClusterStorager) *SubClusterManager

func (*SubClusterManager) CreateSubCluster

func (scm *SubClusterManager) CreateSubCluster(ctx context.Context, product *ibasic.Product, param *SubClusterParam) (err error)

func (*SubClusterManager) DeleteSubCluster

func (scm *SubClusterManager) DeleteSubCluster(ctx context.Context, subCluster *SubCluster) (err error)

func (*SubClusterManager) FetchSubCluster

func (scm *SubClusterManager) FetchSubCluster(ctx context.Context, param *SubClusterFilter) (subCluster *SubCluster, err error)

func (*SubClusterManager) SubClusterList

func (scm *SubClusterManager) SubClusterList(ctx context.Context, param *SubClusterFilter) (list []*SubCluster, err error)

func (*SubClusterManager) UpdateSubCluster

func (scm *SubClusterManager) UpdateSubCluster(ctx context.Context, subCluster *SubCluster, param *SubClusterParam) (err error)

type SubClusterParam

type SubClusterParam struct {
	ID   *int64
	Name *string

	PoolID       *int64
	PoolName     *string
	InstancePool *Pool

	Product *ibasic.Product

	ClusterName *string
	Cluster     *Cluster
	ClusterIDs  []int64

	Description *string
}

type SubClusterStorager

type SubClusterStorager interface {
	FetchSubClusterList(ctx context.Context, param *SubClusterFilter) ([]*SubCluster, error)
	CreateSubCluster(ctx context.Context, param *SubClusterParam) error
	DeleteSubCluster(ctx context.Context, param *SubCluster) error
	UpdateSubCluster(ctx context.Context, one *SubCluster, param *SubClusterParam) error
}

Jump to

Keyboard shortcuts

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