MCPcopy Create free account
hub / github.com/apache/incubator-pegasus / executeCommand

Function executeCommand

admin-cli/cmd/server_config.go:69–91  ·  view source on GitHub ↗
(c *grumble.Context, ntype session.NodeType)

Source from the content-addressed store, hash-verified

67}
68
69func executeCommand(c *grumble.Context, ntype session.NodeType) error {
70 defer func() {
71 if err := recover(); err != nil {
72 println(errMsg().Error())
73 }
74 }()
75
76 cmd := c.Args.StringList("command")
77 if len(cmd) == 0 {
78 return errMsg()
79 }
80 if len(cmd) == 1 && cmd[0] == "list" {
81 return executor.ConfigCommand(pegasusClient, ntype, c.Flags.String("node"), "", "list", "0")
82 }
83 if len(cmd) == 2 && cmd[1] == "get" {
84 return executor.ConfigCommand(pegasusClient, ntype, c.Flags.String("node"), cmd[0], "get", "0")
85 }
86 if len(cmd) == 3 && cmd[1] == "set" {
87 return executor.ConfigCommand(pegasusClient, ntype, c.Flags.String("node"), cmd[0], "set", cmd[2])
88 }
89
90 return errMsg()
91}
92
93func errMsg() error {
94 return fmt.Errorf("invalid command: \n\tconfig-commad meta/replica list: query all config\n\tconfig-commad" +

Callers 1

initFunction · 0.85

Calls 4

recoverFunction · 0.85
errMsgFunction · 0.85
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected