models

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0, MIT, MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrKeyConfigFileList = "config_files"
	AttrKeyLogFileList    = "log_files"
	AttrKeyMetricsDir     = "metrics_dir"
)

Some predefined key names for extended metadata

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeMap

type AttributeMap map[string]interface{}

AttributeMap are extended key-values related to an object

func (AttributeMap) AddConfigFile

func (attr AttributeMap) AddConfigFile(p string)

AddConfigFile inserts path of a config file to the list

func (AttributeMap) AddLogFile

func (attr AttributeMap) AddLogFile(p string)

AddLogFile inserts path of a log file to the list

func (AttributeMap) SetMetricsDir

func (attr AttributeMap) SetMetricsDir(p string)

SetMetricsDir sets the path of metrics files

type Component

type Component interface {
	Type() ComponentType
	Host() string
	MainPort() int
	StatusPort() int
	SSHPort() int      // empty for tidb-operator
	ID() string        // host:port identifier
	StatusURL() string // the url to request for compoent status, without http/https scheme
	ConfigURL() string // the url to request for realtime configs, without http/https scheme
	Attributes() AttributeMap
}

Component is the interface for any component

func FilterComponent

func FilterComponent(comps []Component, components set.StringSet) (res []Component)

FilterComponent filter components by set

func FilterInstance

func FilterInstance(instances []Component, nodes set.StringSet) (res []Component)

FilterInstance filter instances by set

type ComponentSpec

type ComponentSpec struct {
	Host       string       `json:"host"`
	Port       int          `json:"port"`
	StatusPort int          `json:"status_port"`
	SSHPort    int          `json:"ssh_port,omitempty"`
	Attributes AttributeMap `json:"attributes,omitempty"`
}

ComponentSpec is the definition of general component

type ComponentType

type ComponentType string

ComponentType are types of a component

const (
	ComponentTypePD       ComponentType = "pd"
	ComponentTypeTiKV     ComponentType = "tikv"
	ComponentTypeTiDB     ComponentType = "tidb"
	ComponentTypeTiFlash  ComponentType = "tiflash"
	ComponentTypePump     ComponentType = "pump"
	ComponentTypeDrainer  ComponentType = "drainer"
	ComponentTypeTiCDC    ComponentType = "ticdc"
	ComponentTypeTiSpark  ComponentType = "tispark"
	ComponentTypeMonitor  ComponentType = "prometheus" // prometheus and/or ng-monitor
	ComponentTypeDMMaster ComponentType = "dm-master"
	ComponentTypeDMWorker ComponentType = "dm-worker"
)

types for components

type DMMasterSpec

type DMMasterSpec struct {
	ComponentSpec `json:",inline"`
}

DMMaterSpec represent PD nodes

func (*DMMasterSpec) Attributes

func (s *DMMasterSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*DMMasterSpec) ConfigURL

func (s *DMMasterSpec) ConfigURL() string

ConfigURL implements Component interface

func (*DMMasterSpec) Domain

func (s *DMMasterSpec) Domain() string

Domain implements Component interface

func (*DMMasterSpec) Host

func (s *DMMasterSpec) Host() string

Host implements Component interface

func (*DMMasterSpec) ID

func (s *DMMasterSpec) ID() string

ID implements Component interface

func (*DMMasterSpec) MainPort

func (s *DMMasterSpec) MainPort() int

MainPort implements Component interface

func (*DMMasterSpec) SSHPort

func (s *DMMasterSpec) SSHPort() int

SSHPort implements Component interface

func (*DMMasterSpec) StatusPort

func (s *DMMasterSpec) StatusPort() int

StatusPort implements Component interface

func (*DMMasterSpec) StatusURL

func (s *DMMasterSpec) StatusURL() string

StatusURL implements Component interface

func (*DMMasterSpec) Type

func (s *DMMasterSpec) Type() ComponentType

Type implements Component interface

type DMWorkerSpec

type DMWorkerSpec struct {
	ComponentSpec `json:",inline"`
}

DMWorkerSpec represent PD nodes

func (*DMWorkerSpec) Attributes

func (s *DMWorkerSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*DMWorkerSpec) ConfigURL

func (s *DMWorkerSpec) ConfigURL() string

ConfigURL implements Component interface

func (*DMWorkerSpec) Domain

func (s *DMWorkerSpec) Domain() string

Domain implements Component interface

func (*DMWorkerSpec) Host

func (s *DMWorkerSpec) Host() string

Host implements Component interface

func (*DMWorkerSpec) ID

func (s *DMWorkerSpec) ID() string

ID implements Component interface

func (*DMWorkerSpec) MainPort

func (s *DMWorkerSpec) MainPort() int

MainPort implements Component interface

func (*DMWorkerSpec) SSHPort

func (s *DMWorkerSpec) SSHPort() int

SSHPort implements Component interface

func (*DMWorkerSpec) StatusPort

func (s *DMWorkerSpec) StatusPort() int

StatusPort implements Component interface

func (*DMWorkerSpec) StatusURL

func (s *DMWorkerSpec) StatusURL() string

StatusURL implements Component interface

func (*DMWorkerSpec) Type

func (s *DMWorkerSpec) Type() ComponentType

Type implements Component interface

type DrainerSpec

type DrainerSpec struct {
	ComponentSpec `json:",inline"`
}

DrainerSpec represent PD nodes

func (*DrainerSpec) Attributes

func (s *DrainerSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*DrainerSpec) ConfigURL

func (s *DrainerSpec) ConfigURL() string

ConfigURL implements Component interface

func (*DrainerSpec) Domain

func (s *DrainerSpec) Domain() string

Domain implements Component interface

func (*DrainerSpec) Host

func (s *DrainerSpec) Host() string

Host implements Component interface

func (*DrainerSpec) ID

func (s *DrainerSpec) ID() string

ID implements Component interface

func (*DrainerSpec) MainPort

func (s *DrainerSpec) MainPort() int

MainPort implements Component interface

func (*DrainerSpec) SSHPort

func (s *DrainerSpec) SSHPort() int

SSHPort implements Component interface

func (*DrainerSpec) StatusPort

func (s *DrainerSpec) StatusPort() int

StatusPort implements Component interface

func (*DrainerSpec) StatusURL

func (s *DrainerSpec) StatusURL() string

StatusURL implements Component interface

func (*DrainerSpec) Type

func (s *DrainerSpec) Type() ComponentType

Type implements Component interface

type MonitorSpec

type MonitorSpec struct {
	ComponentSpec `json:",inline"`
	Endpoint      string `json:"endpoint,omitempty"`    // the metric endpoint, normally prometheus address
	NGEndpoint    string `json:"ng_endpoint,omitempty"` // the endpoint of NG-monitor, might be empty
}

MonitorSpec is the spec needed for monitoring nodes

func (*MonitorSpec) Attributes

func (s *MonitorSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*MonitorSpec) ConfigURL

func (s *MonitorSpec) ConfigURL() string

ConfigURL implements Component interface

func (*MonitorSpec) Domain

func (s *MonitorSpec) Domain() string

Domain implements Component interface

func (*MonitorSpec) Host

func (s *MonitorSpec) Host() string

Host implements Component interface

func (*MonitorSpec) ID

func (s *MonitorSpec) ID() string

ID implements Component interface

func (*MonitorSpec) MainPort

func (s *MonitorSpec) MainPort() int

MainPort implements Component interface

func (*MonitorSpec) SSHPort

func (s *MonitorSpec) SSHPort() int

SSHPort implements Component interface

func (*MonitorSpec) StatusPort

func (s *MonitorSpec) StatusPort() int

StatusPort implements Component interface

func (*MonitorSpec) StatusURL

func (s *MonitorSpec) StatusURL() string

StatusURL implements Component interface

func (*MonitorSpec) Type

func (s *MonitorSpec) Type() ComponentType

Type implements Component interface

type PDSpec

type PDSpec struct {
	ComponentSpec `json:",inline"`
}

PDSpec represent PD nodes

func (*PDSpec) Attributes

func (s *PDSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*PDSpec) ConfigURL

func (s *PDSpec) ConfigURL() string

ConfigURL implements Component interface

func (*PDSpec) Domain

func (s *PDSpec) Domain() string

Domain implements Component interface

func (*PDSpec) Host

func (s *PDSpec) Host() string

Host implements Component interface

func (*PDSpec) ID

func (s *PDSpec) ID() string

ID implements Component interface

func (*PDSpec) MainPort

func (s *PDSpec) MainPort() int

MainPort implements Component interface

func (*PDSpec) SSHPort

func (s *PDSpec) SSHPort() int

SSHPort implements Component interface

func (*PDSpec) StatusPort

func (s *PDSpec) StatusPort() int

StatusPort implements Component interface

func (*PDSpec) StatusURL

func (s *PDSpec) StatusURL() string

StatusURL implements Component interface

func (*PDSpec) Type

func (s *PDSpec) Type() ComponentType

Type implements Component interface

type PumpSpec

type PumpSpec struct {
	ComponentSpec `json:",inline"`
}

PumpSpec represent PD nodes

func (*PumpSpec) Attributes

func (s *PumpSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*PumpSpec) ConfigURL

func (s *PumpSpec) ConfigURL() string

ConfigURL implements Component interface

func (*PumpSpec) Domain

func (s *PumpSpec) Domain() string

Domain implements Component interface

func (*PumpSpec) Host

func (s *PumpSpec) Host() string

Host implements Component interface

func (*PumpSpec) ID

func (s *PumpSpec) ID() string

ID implements Component interface

func (*PumpSpec) MainPort

func (s *PumpSpec) MainPort() int

MainPort implements Component interface

func (*PumpSpec) SSHPort

func (s *PumpSpec) SSHPort() int

SSHPort implements Component interface

func (*PumpSpec) StatusPort

func (s *PumpSpec) StatusPort() int

StatusPort implements Component interface

func (*PumpSpec) StatusURL

func (s *PumpSpec) StatusURL() string

StatusURL implements Component interface

func (*PumpSpec) Type

func (s *PumpSpec) Type() ComponentType

Type implements Component interface

type TiCDCSpec

type TiCDCSpec struct {
	ComponentSpec `json:",inline"`
}

TiCDCSpec represent PD nodes

func (*TiCDCSpec) Attributes

func (s *TiCDCSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*TiCDCSpec) ConfigURL

func (s *TiCDCSpec) ConfigURL() string

ConfigURL implements Component interface

func (*TiCDCSpec) Domain

func (s *TiCDCSpec) Domain() string

Domain implements Component interface

func (*TiCDCSpec) Host

func (s *TiCDCSpec) Host() string

Host implements Component interface

func (*TiCDCSpec) ID

func (s *TiCDCSpec) ID() string

ID implements Component interface

func (*TiCDCSpec) MainPort

func (s *TiCDCSpec) MainPort() int

MainPort implements Component interface

func (*TiCDCSpec) SSHPort

func (s *TiCDCSpec) SSHPort() int

SSHPort implements Component interface

func (*TiCDCSpec) StatusPort

func (s *TiCDCSpec) StatusPort() int

StatusPort implements Component interface

func (*TiCDCSpec) StatusURL

func (s *TiCDCSpec) StatusURL() string

StatusURL implements Component interface

func (*TiCDCSpec) Type

func (s *TiCDCSpec) Type() ComponentType

Type implements Component interface

type TiDBCluster

type TiDBCluster struct {
	Version    string          `json:"version"` // cluster version
	Namespace  string          `json:"namespace,omitempty"`
	Attributes AttributeMap    `json:"attributes,omitempty"`
	PD         []*PDSpec       `json:"pd,omitempty"` // PD not exist on DM cluster
	TiKV       []*TiKVSpec     `json:"tikv,omitempty"`
	TiDB       []*TiDBSpec     `json:"tidb,omitempty"`
	TiFlash    []*TiFlashSpec  `json:"tiflash,omitempty"`
	TiCDC      []*TiCDCSpec    `json:"ticdc,omitempty"`
	Pump       []*PumpSpec     `json:"pump,omitempty"`
	Drainer    []*DrainerSpec  `json:"drainer,omitempty"`
	TiSpark    []*TiSparkCSpec `json:"tispark,omitempty"`
	DMMaster   []*DMMasterSpec `json:"dm-master,omitempty"`
	DMWorker   []*DMWorkerSpec `json:"dm-worker,omitempty"`
	Monitors   []*MonitorSpec  `json:"monitors,omitempty"` // prometheus nodes
}

TiDBCluster is the abstract topology of a TiDB cluster

func (*TiDBCluster) Components

func (c *TiDBCluster) Components() (comps []Component)

Components list all available components in the cluster

func (*TiDBCluster) GetAllCDCInfo

func (c *TiDBCluster) GetAllCDCInfo(ctx context.Context, timeout time.Duration, tlsCfg *tls.Config) ([]*mvccpb.KeyValue, error)

getAllCDCInfo get all keys created by CDC

func (*TiDBCluster) GetEtcdClient

func (c *TiDBCluster) GetEtcdClient(tlsCfg *tls.Config) (*clientv3.Client, error)

GetEtcdClient loads EtcdClient of current cluster

type TiDBSpec

type TiDBSpec struct {
	ComponentSpec `json:",inline"`
}

TiDBSpec represent PD nodes

func (*TiDBSpec) Attributes

func (s *TiDBSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*TiDBSpec) ConfigURL

func (s *TiDBSpec) ConfigURL() string

ConfigURL implements Component interface

func (*TiDBSpec) Domain

func (s *TiDBSpec) Domain() string

Domain implements Component interface

func (*TiDBSpec) Host

func (s *TiDBSpec) Host() string

Host implements Component interface

func (*TiDBSpec) ID

func (s *TiDBSpec) ID() string

ID implements Component interface

func (*TiDBSpec) MainPort

func (s *TiDBSpec) MainPort() int

MainPort implements Component interface

func (*TiDBSpec) SSHPort

func (s *TiDBSpec) SSHPort() int

SSHPort implements Component interface

func (*TiDBSpec) StatusPort

func (s *TiDBSpec) StatusPort() int

StatusPort implements Component interface

func (*TiDBSpec) StatusURL

func (s *TiDBSpec) StatusURL() string

StatusURL implements Component interface

func (*TiDBSpec) Type

func (s *TiDBSpec) Type() ComponentType

Type implements Component interface

type TiFlashSpec

type TiFlashSpec struct {
	ComponentSpec `json:",inline"`
}

TiFlashSpec represent PD nodes

func (*TiFlashSpec) Attributes

func (s *TiFlashSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*TiFlashSpec) ConfigURL

func (s *TiFlashSpec) ConfigURL() string

ConfigURL implements Component interface

func (*TiFlashSpec) Domain

func (s *TiFlashSpec) Domain() string

Domain implements Component interface

func (*TiFlashSpec) Host

func (s *TiFlashSpec) Host() string

Host implements Component interface

func (*TiFlashSpec) ID

func (s *TiFlashSpec) ID() string

ID implements Component interface

func (*TiFlashSpec) MainPort

func (s *TiFlashSpec) MainPort() int

MainPort implements Component interface

func (*TiFlashSpec) SSHPort

func (s *TiFlashSpec) SSHPort() int

SSHPort implements Component interface

func (*TiFlashSpec) StatusPort

func (s *TiFlashSpec) StatusPort() int

StatusPort implements Component interface

func (*TiFlashSpec) StatusURL

func (s *TiFlashSpec) StatusURL() string

StatusURL implements Component interface

func (*TiFlashSpec) Type

func (s *TiFlashSpec) Type() ComponentType

Type implements Component interface

type TiKVSpec

type TiKVSpec struct {
	ComponentSpec `json:",inline"`
}

TiKVSpec represent PD nodes

func (*TiKVSpec) Attributes

func (s *TiKVSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*TiKVSpec) ConfigURL

func (s *TiKVSpec) ConfigURL() string

ConfigURL implements Component interface

func (*TiKVSpec) Domain

func (s *TiKVSpec) Domain() string

Domain implements Component interface

func (*TiKVSpec) Host

func (s *TiKVSpec) Host() string

Host implements Component interface

func (*TiKVSpec) ID

func (s *TiKVSpec) ID() string

ID implements Component interface

func (*TiKVSpec) MainPort

func (s *TiKVSpec) MainPort() int

MainPort implements Component interface

func (*TiKVSpec) SSHPort

func (s *TiKVSpec) SSHPort() int

SSHPort implements Component interface

func (*TiKVSpec) StatusPort

func (s *TiKVSpec) StatusPort() int

StatusPort implements Component interface

func (*TiKVSpec) StatusURL

func (s *TiKVSpec) StatusURL() string

StatusURL implements Component interface

func (*TiKVSpec) Type

func (s *TiKVSpec) Type() ComponentType

Type implements Component interface

type TiSparkCSpec

type TiSparkCSpec struct {
	ComponentSpec `json:",inline"`
	Master        bool `json:"master"`
}

TiSparkCSpec represent PD nodes

func (*TiSparkCSpec) Attributes

func (s *TiSparkCSpec) Attributes() AttributeMap

Attributes implements Component interface

func (*TiSparkCSpec) ConfigURL

func (s *TiSparkCSpec) ConfigURL() string

ConfigURL implements Component interface

func (*TiSparkCSpec) Domain

func (s *TiSparkCSpec) Domain() string

Domain implements Component interface

func (*TiSparkCSpec) Host

func (s *TiSparkCSpec) Host() string

Host implements Component interface

func (*TiSparkCSpec) ID

func (s *TiSparkCSpec) ID() string

ID implements Component interface

func (*TiSparkCSpec) IsMaster

func (s *TiSparkCSpec) IsMaster() bool

IsMster checks if the node is a TiSpark master

func (*TiSparkCSpec) MainPort

func (s *TiSparkCSpec) MainPort() int

MainPort implements Component interface

func (*TiSparkCSpec) SSHPort

func (s *TiSparkCSpec) SSHPort() int

SSHPort implements Component interface

func (*TiSparkCSpec) StatusPort

func (s *TiSparkCSpec) StatusPort() int

StatusPort implements Component interface

func (*TiSparkCSpec) StatusURL

func (s *TiSparkCSpec) StatusURL() string

StatusURL implements Component interface

func (*TiSparkCSpec) Type

func (s *TiSparkCSpec) Type() ComponentType

Type implements Component interface

Jump to

Keyboard shortcuts

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