Documentation ¶
Index ¶
- Constants
- Variables
- func AdjustArgumentsForPflags(args []string) []string
- func DefineConfigFlagSet(fs *pflag.FlagSet)
- func ExtractSQLsFromArgs(args []string) ([]string, error)
- func GetFileContent(fpath string) ([]byte, error)
- func GetSourceArgs(cmd *cobra.Command) ([]string, error)
- func GetTaskNameFromArgOrFile(arg string) string
- func InitClient(addr string, securityCfg security.Security) error
- func InitUtils(cfg *Config) error
- func OperateRelay(op pb.RelayOp, workers []string) (*pb.OperateWorkerRelayResponse, error)
- func OperateTask(op pb.TaskOp, name string, sources []string) (*pb.OperateTaskResponse, error)
- func PrettyPrintInterface(resp interface{})
- func PrettyPrintResponse(resp proto.Message)
- func PrettyPrintResponseWithCheckTask(resp proto.Message, subStr string) bool
- func PrintCmdUsage(cmd *cobra.Command)
- func PrintLinesf(format string, a ...interface{})
- func SendRequest(ctx context.Context, reqName string, req interface{}, respPointer interface{}) error
- func SplitArgsRespectQuote(line string) []string
- type Config
- type CtlClient
Constants ¶
const ( // Master specifies member master type. Master = "master" // Worker specifies member worker type. Worker = "worker" // DefaultErrorCnt represents default count of errors to display for check-task. DefaultErrorCnt = 10 // DefaultWarnCnt represents count of warns to display for check-task. DefaultWarnCnt = 10 )
Variables ¶
var ( // GlobalCtlClient is the globally used CtlClient in this package. Exposed to be used in test. GlobalCtlClient = &CtlClient{} )
Functions ¶
func AdjustArgumentsForPflags ¶
AdjustArgumentsForPflags adjust flag format args to pflags format.
func DefineConfigFlagSet ¶
DefineConfigFlagSet defines flag definitions for configs.
func ExtractSQLsFromArgs ¶
ExtractSQLsFromArgs extract multiple sql from args.
func GetFileContent ¶
GetFileContent reads and returns file's content.
func GetSourceArgs ¶
GetSourceArgs extracts sources from cmd.
func GetTaskNameFromArgOrFile ¶
GetTaskNameFromArgOrFile tries to retrieve name from the file if arg is yaml-filename-like, otherwise returns arg directly.
func InitClient ¶
InitClient initializes dm-master client.
func OperateRelay ¶
OperateRelay does operation on relay unit.
func OperateTask ¶
OperateTask does operation on task.
func PrettyPrintInterface ¶
func PrettyPrintInterface(resp interface{})
PrettyPrintInterface prints an interface through encoding/json prettily.
func PrettyPrintResponse ¶
PrettyPrintResponse prints a PRC response prettily.
func PrettyPrintResponseWithCheckTask ¶
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 PrintCmdUsage ¶
PrintCmdUsage prints the usage of the command.
func PrintLinesf ¶
func PrintLinesf(format string, a ...interface{})
PrintLinesf adds a wrap to support `\n` within `chzyer/readline`.
func SendRequest ¶
func SendRequest(ctx context.Context, reqName string, req interface{}, respPointer interface{}) error
SendRequest send request to master.
func SplitArgsRespectQuote ¶
SplitArgsRespectQuote splits args by space, but won't split space inside single or double quotes.
Types ¶
type Config ¶
type Config struct { *pflag.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"` security.Security }
Config is the configuration.