common

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EncryptCmdName is special command
	EncryptCmdName = "encrypt"
	// DecryptCmdName is special command
	DecryptCmdName = "decrypt"
)

Variables

This section is empty.

Functions

func ExtractSQLsFromArgs

func ExtractSQLsFromArgs(args []string) ([]string, error)

ExtractSQLsFromArgs extract multiple sql from args.

func GetFileContent

func GetFileContent(fpath string) ([]byte, error)

GetFileContent reads and returns file's content

func GetWorkerArgs

func GetWorkerArgs(cmd *cobra.Command) ([]string, error)

GetWorkerArgs extracts workers from cmd

func InitClient

func InitClient(addr string) error

InitClient initializes dm-master client

func InitUtils

func InitUtils(cfg *Config) error

InitUtils inits necessary dmctl utils

func IsDDL

func IsDDL(sql string) (bool, error)

IsDDL tests whether the input is a valid DDL statement

func MasterClient

func MasterClient() pb.MasterClient

MasterClient returns dm-master client

func OperateRelay

func OperateRelay(op pb.RelayOp, workers []string) (*pb.OperateWorkerRelayResponse, error)

OperateRelay does operation on relay unit

func OperateTask

func OperateTask(op pb.TaskOp, name string, workers []string) (*pb.OperateTaskResponse, error)

OperateTask does operation on task

func PrettyPrintInterface added in v1.0.2

func PrettyPrintInterface(resp interface{})

PrettyPrintInterface prints an interface through encoding/json prettily

func PrettyPrintResponse

func PrettyPrintResponse(resp proto.Message)

PrettyPrintResponse prints a PRC response prettily

func PrettyPrintResponseWithCheckTask

func PrettyPrintResponseWithCheckTask(resp proto.Message, subStr string) bool

PrettyPrintResponseWithCheckTask prints a RPC response may contain response Msg with check-task's response prettily. check-task's response may contain json-string when checking fail in `detail` field. ugly code, but it is a little hard to refine this because needing to convert type.

func PrintLines

func PrintLines(format string, a ...interface{})

PrintLines adds a wrap to support `\n` within `chzyer/readline`

Types

type Config

type Config struct {
	*flag.FlagSet `json:"-"`

	MasterAddr string `toml:"master-addr" json:"master-addr"`

	RPCTimeoutStr string        `toml:"rpc-timeout" json:"rpc-timeout"`
	RPCTimeout    time.Duration `json:"-"`

	ConfigFile string `json:"config-file"`
	// contains filtered or unexported fields
}

Config is the configuration.

func GlobalConfig

func GlobalConfig() *Config

GlobalConfig returns global dmctl config

func NewConfig

func NewConfig() *Config

NewConfig creates a new base config for dmctl.

func (*Config) Parse

func (c *Config) Parse(arguments []string) (finish bool, err error)

Parse parses flag definitions from the argument list.

func (*Config) String

func (c *Config) String() string

func (*Config) Validate added in v1.0.3

func (c *Config) Validate() error

Validate check config is ready to execute commmand

Jump to

Keyboard shortcuts

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