basecmd

package
v0.0.0-...-e1dd21f Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CURL_VERSION = "curl/7.54.0"
)

Variables

This section is empty.

Functions

func GetFileInode

func GetFileInode(path string) (uint64, error)

get mountPoint inode

func GetKeyValueFromJsonMetric

func GetKeyValueFromJsonMetric(metricRet string, key string) (string, *cmderror.CmdError)

func GetMdsLeader

func GetMdsLeader(mdsAddrs []string) (string, bool)

get mds leader server

func GetMetricValue

func GetMetricValue(metricRet string) (string, *cmderror.CmdError)

func GetResuestHosts

func GetResuestHosts(reqAddrs []string) []string

get request hosts

func GetRpcListResponse

func GetRpcListResponse(rpcList []*Rpc, rpcFunc []RpcFunc) ([]interface{}, []*cmderror.CmdError)

func GetRpcResponse

func GetRpcResponse(rpc *Rpc, rpcFunc RpcFunc) (interface{}, *cmderror.CmdError)

func NewFinalDingoCli

func NewFinalDingoCli(cli *FinalDingoCmd, funcs FinalDingoCmdFunc) *cobra.Command

func NewMidDingoCli

func NewMidDingoCli(cli *MidDingoCmd, add MidDingoCmdFunc) *cobra.Command

func QueryMetric

func QueryMetric(m *Metric) (string, *cmderror.CmdError)

Types

type ConnectionPool

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

func NewConnectionPool

func NewConnectionPool() *ConnectionPool

func (*ConnectionPool) GetConnection

func (c *ConnectionPool) GetConnection(address string, timeout time.Duration) (*grpc.ClientConn, error)

func (*ConnectionPool) PutConnection

func (c *ConnectionPool) PutConnection(address string, conn *grpc.ClientConn)

func (*ConnectionPool) Release

func (c *ConnectionPool) Release(address string)

type FinalDingoCmd

type FinalDingoCmd struct {
	Use      string             `json:"-"`
	Short    string             `json:"-"`
	Long     string             `json:"-"`
	Example  string             `json:"-"`
	Error    *cmderror.CmdError `json:"error"`
	Result   interface{}        `json:"result"`
	TableNew *tablewriter.Table `json:"-"`
	Header   []string           `json:"-"`
	Cmd      *cobra.Command     `json:"-"`
}

FinalDingoCmd is the final executable command, it has no subcommands. The execution process is Init->RunCommand->Print. Error Use to indicate whether the command is wrong and the reason for the execution error

func (*FinalDingoCmd) SetHeader

func (fc *FinalDingoCmd) SetHeader(header []string)

type FinalDingoCmdFunc

type FinalDingoCmdFunc interface {
	Init(cmd *cobra.Command, args []string) error
	RunCommand(cmd *cobra.Command, args []string) error
	Print(cmd *cobra.Command, args []string) error
	// result in plain format string
	ResultPlainOutput() error
	AddFlags()
}

FinalDingoCmdFunc is the function type for final command If there is flag[required] related code should not be placed in init, the check for it is placed between PreRun and Run

type LeaderMetaCache

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

type Metric

type Metric struct {
	Addrs  []string
	SubUri string
	// contains filtered or unexported fields
}

func NewMetric

func NewMetric(addrs []string, subUri string, timeout time.Duration) *Metric

type MetricResult

type MetricResult struct {
	Addr  string
	Key   string
	Value string
	Err   *cmderror.CmdError
}

type MidDingoCmd

type MidDingoCmd struct {
	Use   string
	Short string
	Cmd   *cobra.Command
}

MidDingoCmd is the middle command and has subcommands. If you execute this command you will be prompted which subcommands are included

type MidDingoCmdFunc

type MidDingoCmdFunc interface {
	AddSubCommands()
}

Add subcommand for MidDingoCmd

type Result

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

type Rpc

type Rpc struct {
	Addrs         []string
	RpcTimeout    time.Duration
	RpcRetryTimes int32
	RpcFuncName   string
	RpcDataShow   bool
}

func NewRpc

func NewRpc(addrs []string, timeout time.Duration, retryTimes int32, funcName string) *Rpc

TODO field RpcDataShow may be pass by parameter

type RpcFunc

type RpcFunc interface {
	NewRpcClient(cc grpc.ClientConnInterface)
	Stub_Func(ctx context.Context) (interface{}, error)
}

type RpcResult

type RpcResult struct {
	Response interface{}
	Error    *cmderror.CmdError
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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