instance

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SysProcAttr = &syscall.SysProcAttr{
	Pdeathsig: syscall.SIGKILL,
	Setpgid:   true,
}

SysProcAttr to be use for every Process we start.

Functions

func AdvertiseHost

func AdvertiseHost(listen string) string

AdvertiseHost returns the interface's ip addr if listen host is 0.0.0.0

func CompVersion

func CompVersion(comp string, version utils.Version) string

CompVersion return the format to run specified version of a component.

Types

type Config

type Config struct {
	ConfigPath string `yaml:"config_path"`
	BinPath    string `yaml:"bin_path"`
	Num        int    `yaml:"num"`
	Host       string `yaml:"host"`
	Port       int    `yaml:"port"`
	UpTimeout  int    `yaml:"up_timeout"`
}

Config of the instance.

type Drainer

type Drainer struct {
	Process
	// contains filtered or unexported fields
}

Drainer represent a drainer instance.

func NewDrainer

func NewDrainer(binPath string, dir, host, configPath string, id int, pds []*PDInstance) *Drainer

NewDrainer create a Drainer instance.

func (*Drainer) Addr

func (d *Drainer) Addr() string

Addr return the address of Drainer.

func (*Drainer) Component

func (d *Drainer) Component() string

Component return component name.

func (*Drainer) LogFile

func (d *Drainer) LogFile() string

LogFile return the log file name.

func (*Drainer) NodeID

func (d *Drainer) NodeID() string

NodeID return the node id of drainer.

func (*Drainer) Start

func (d *Drainer) Start(ctx context.Context, version utils.Version) error

Start implements Instance interface.

func (*Drainer) StatusAddrs

func (inst *Drainer) StatusAddrs() (addrs []string)

type Instance

type Instance interface {
	Pid() int
	// Start the instance process.
	// Will kill the process once the context is done.
	Start(ctx context.Context, version utils.Version) error
	// Component Return the component name.
	Component() string
	// LogFile return the log file name
	LogFile() string
	// Uptime show uptime.
	Uptime() string
	// StatusAddrs return the address to pull metrics.
	StatusAddrs() []string
	// Wait Should only call this if the instance is started successfully.
	// The implementation should be safe to call Wait multi times.
	Wait() error
}

Instance represent running component

type PDInstance

type PDInstance struct {
	Process
	// contains filtered or unexported fields
}

PDInstance represent a running pd-server

func NewPDInstance

func NewPDInstance(binPath, dir, host, configPath string, id int) *PDInstance

NewPDInstance return a PDInstance

func (*PDInstance) Addr

func (inst *PDInstance) Addr() string

Addr return the listen address of PD

func (*PDInstance) Component

func (inst *PDInstance) Component() string

Component return the component name.

func (*PDInstance) InitCluster

func (inst *PDInstance) InitCluster(pds []*PDInstance) *PDInstance

InitCluster set the init cluster instance.

func (*PDInstance) Join

func (inst *PDInstance) Join(pds []*PDInstance) *PDInstance

Join set endpoints field of PDInstance

func (*PDInstance) LogFile

func (inst *PDInstance) LogFile() string

LogFile return the log file.

func (*PDInstance) Name

func (inst *PDInstance) Name() string

Name return the name of pd.

func (*PDInstance) Start

func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

func (*PDInstance) StatusAddrs

func (inst *PDInstance) StatusAddrs() (addrs []string)

type Process

type Process interface {
	Start() error
	Wait() error
	Pid() int
	Uptime() string
	SetOutputFile(fname string) error
	Cmd() *exec.Cmd
}

Process represent process to be run by playground

func NewComponentProcess

func NewComponentProcess(ctx context.Context, dir, binPath, component string, version utils.Version, arg ...string) (Process, error)

NewComponentProcess create a Process instance.

func NewComponentProcessWithEnvs

func NewComponentProcessWithEnvs(ctx context.Context, dir, binPath, component string, version utils.Version, envs map[string]string, arg ...string) (Process, error)

NewComponentProcessWithEnvs create a Process instance with given environment variables.

type Pump

type Pump struct {
	Process
	// contains filtered or unexported fields
}

Pump represent a pump instance.

func NewPump

func NewPump(binPath string, dir, host, configPath string, id int, pds []*PDInstance) *Pump

NewPump create a Pump instance.

func (*Pump) Addr

func (p *Pump) Addr() string

Addr return the address of Pump.

func (*Pump) Component

func (p *Pump) Component() string

Component return component name.

func (*Pump) LogFile

func (p *Pump) LogFile() string

LogFile return the log file.

func (*Pump) NodeID

func (p *Pump) NodeID() string

NodeID return the node id of pump.

func (*Pump) Ready

func (p *Pump) Ready(ctx context.Context) error

Ready return nil when pump is ready to serve.

func (*Pump) Start

func (p *Pump) Start(ctx context.Context, version utils.Version) error

Start implements Instance interface.

func (*Pump) StatusAddrs

func (inst *Pump) StatusAddrs() (addrs []string)

type TiCDC

type TiCDC struct {
	Process
	// contains filtered or unexported fields
}

TiCDC represent a ticdc instance.

func NewTiCDC

func NewTiCDC(binPath string, dir, host, configPath string, id int, pds []*PDInstance) *TiCDC

NewTiCDC create a TiCDC instance.

func (*TiCDC) Component

func (c *TiCDC) Component() string

Component return component name.

func (*TiCDC) LogFile

func (c *TiCDC) LogFile() string

LogFile return the log file.

func (*TiCDC) Start

func (c *TiCDC) Start(ctx context.Context, version utils.Version) error

Start implements Instance interface.

func (*TiCDC) StatusAddrs

func (inst *TiCDC) StatusAddrs() (addrs []string)

type TiDBInstance

type TiDBInstance struct {
	Process
	// contains filtered or unexported fields
}

TiDBInstance represent a running tidb-server

func NewTiDBInstance

func NewTiDBInstance(binPath string, dir, host, configPath string, id, port int, pds []*PDInstance, enableBinlog bool) *TiDBInstance

NewTiDBInstance return a TiDBInstance

func (*TiDBInstance) Addr

func (inst *TiDBInstance) Addr() string

Addr return the listen address of TiDB

func (*TiDBInstance) Component

func (inst *TiDBInstance) Component() string

Component return the component name.

func (*TiDBInstance) LogFile

func (inst *TiDBInstance) LogFile() string

LogFile return the log file name.

func (*TiDBInstance) Start

func (inst *TiDBInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

func (*TiDBInstance) StatusAddrs

func (inst *TiDBInstance) StatusAddrs() (addrs []string)

type TiFlashInstance

type TiFlashInstance struct {
	TCPPort         int
	ServicePort     int
	ProxyPort       int
	ProxyStatusPort int
	ProxyConfigPath string

	Process
	// contains filtered or unexported fields
}

TiFlashInstance represent a running TiFlash

func NewTiFlashInstance

func NewTiFlashInstance(binPath, dir, host, configPath string, id int, pds []*PDInstance, dbs []*TiDBInstance) *TiFlashInstance

NewTiFlashInstance return a TiFlashInstance

func (*TiFlashInstance) Addr

func (inst *TiFlashInstance) Addr() string

Addr return the address of tiflash

func (*TiFlashInstance) Cmd

func (inst *TiFlashInstance) Cmd() *exec.Cmd

Cmd returns the internal Cmd instance

func (*TiFlashInstance) Component

func (inst *TiFlashInstance) Component() string

Component return the component name.

func (*TiFlashInstance) LogFile

func (inst *TiFlashInstance) LogFile() string

LogFile return the log file name.

func (*TiFlashInstance) Start

func (inst *TiFlashInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

func (*TiFlashInstance) StatusAddrs

func (inst *TiFlashInstance) StatusAddrs() (addrs []string)

StatusAddrs implements Instance interface.

func (*TiFlashInstance) StoreAddr

func (inst *TiFlashInstance) StoreAddr() string

StoreAddr return the store address of TiFlash

type TiKVInstance

type TiKVInstance struct {
	Process
	// contains filtered or unexported fields
}

TiKVInstance represent a running tikv-server

func NewTiKVInstance

func NewTiKVInstance(binPath string, dir, host, configPath string, id int, pds []*PDInstance) *TiKVInstance

NewTiKVInstance return a TiKVInstance

func (*TiKVInstance) Addr

func (inst *TiKVInstance) Addr() string

Addr return the address of tikv.

func (*TiKVInstance) Component

func (inst *TiKVInstance) Component() string

Component return the component name.

func (*TiKVInstance) LogFile

func (inst *TiKVInstance) LogFile() string

LogFile return the log file name.

func (*TiKVInstance) Start

func (inst *TiKVInstance) Start(ctx context.Context, version utils.Version) error

Start calls set inst.cmd and Start

func (*TiKVInstance) StatusAddrs

func (inst *TiKVInstance) StatusAddrs() (addrs []string)

func (*TiKVInstance) StoreAddr

func (inst *TiKVInstance) StoreAddr() string

StoreAddr return the store address of TiKV

Jump to

Keyboard shortcuts

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