Go: add more commands and GCS supports (#16741)

### Summary

1. GCS supports
2. More commands
```
RAGFlow(admin)> ping store;
SUCCESS
RAGFlow(admin)> ping engine;
SUCCESS
RAGFlow(admin)> ping cache;
SUCCESS
```

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-08 17:49:02 +08:00
committed by GitHub
parent dc95b1d291
commit 21266286cb
26 changed files with 701 additions and 84 deletions

View File

@@ -47,6 +47,46 @@ func (c *CLI) PingAdmin(cmd *Command) (ResponseIf, error) {
return HandleSimpleResponse(resp, "ping admin")
}
// AdminPingStoreCommand ping object store
func (c *CLI) AdminPingStoreCommand(cmd *Command) (ResponseIf, error) {
resp, err := c.AdminServerClient.Request("GET", "/admin/store", "admin", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to ping object store: %w", err)
}
return HandleSimpleResponse(resp, fmt.Sprintf("ping object store"))
}
// AdminPingEngineCommand ping document engine
func (c *CLI) AdminPingEngineCommand(cmd *Command) (ResponseIf, error) {
resp, err := c.AdminServerClient.Request("GET", "/admin/engine", "admin", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to ping document engine: %w", err)
}
return HandleSimpleResponse(resp, fmt.Sprintf("ping document engine"))
}
// AdminPingMQCommand ping message queue
func (c *CLI) AdminPingMQCommand(cmd *Command) (ResponseIf, error) {
resp, err := c.AdminServerClient.Request("GET", "/admin/queue", "admin", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to ping message queue: %w", err)
}
return HandleSimpleResponse(resp, fmt.Sprintf("ping message queue"))
}
// AdminPingCacheCommand ping cache
func (c *CLI) AdminPingCacheCommand(cmd *Command) (ResponseIf, error) {
resp, err := c.AdminServerClient.Request("GET", "/admin/cache", "web", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to ping cache: %w", err)
}
return HandleSimpleResponse(resp, fmt.Sprintf("ping cache"))
}
// AdminShowVersionCommand show RAGFlow admin version
func (c *CLI) AdminShowVersionCommand(cmd *Command) (ResponseIf, error) {
resp, err := c.AdminServerClient.Request("GET", "/admin/version", "web", nil, nil)
@@ -2633,3 +2673,24 @@ func (c *CLI) AdminShowLogLevelCommand(cmd *Command) (ResponseIf, error) {
return HandleCommonDataResponse(resp, fmt.Sprintf("get log level config"))
}
func (c *CLI) AdminListBucketObjects(cmd *Command) (ResponseIf, error) {
if c.Config.CLIMode != AdminMode {
return nil, fmt.Errorf("this command is only allowed in ADMIN mode or already login")
}
bucketID, ok := cmd.Params["bucket_id"].(string)
if !ok {
return nil, fmt.Errorf("bucket_id not provided")
}
endPoint := fmt.Sprintf("/admin/bucket/%s/objects", bucketID)
resp, err := c.AdminServerClient.Request("GET", endPoint, "web", nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to get bucket objects: %w", err)
}
return HandleCommonResponse(resp, fmt.Sprintf("get bucket objects"))
}

View File

@@ -70,12 +70,30 @@ func (p *Parser) parseAdminLogout() (*Command, error) {
}
func (p *Parser) parseAdminPingServer() (*Command, error) {
cmd := NewCommand("admin_ping_server")
p.nextToken()
// Semicolon is optional
if p.curToken.Type == TokenSemicolon {
p.nextToken() // consume PING
var cmd *Command
switch p.curToken.Type {
case TokenStore:
p.nextToken()
cmd = NewCommand("admin_ping_store")
case TokenEngine:
p.nextToken()
cmd = NewCommand("admin_ping_engine")
case TokenMQ:
p.nextToken()
cmd = NewCommand("admin_ping_mq")
case TokenCache:
p.nextToken()
cmd = NewCommand("admin_ping_cache")
case TokenSemicolon, TokenEOF:
p.nextToken()
cmd = NewCommand("admin_ping_server")
default:
return nil, fmt.Errorf("expected semicolon after PING")
}
return cmd, nil
}

View File

@@ -41,8 +41,16 @@ func (c *CLI) ExecuteAdminCommand(cmd *Command) (ResponseIf, error) {
return c.LoginUserByCommand(cmd)
case "admin_logout":
return c.Logout()
case "admin_ping_store":
return c.AdminPingStoreCommand(cmd)
case "admin_ping_engine":
return c.AdminPingEngineCommand(cmd)
case "admin_ping_mq":
return c.AdminPingMQCommand(cmd)
case "admin_ping_cache":
return c.AdminPingCacheCommand(cmd)
case "admin_ping_server":
return c.PingByCommand(cmd)
return c.PingServerByCommand(cmd)
case "benchmark":
return c.RunBenchmark(cmd)
case "admin_list_services":
@@ -281,6 +289,8 @@ func (c *CLI) ExecuteAdminCommand(cmd *Command) (ResponseIf, error) {
return c.CommonUseAPIServerCommand(cmd)
case "admin_use_admin_server":
return c.CommonUseAdminServerCommand(cmd)
case "admin_list_bucket_objects":
return c.AdminListBucketObjects(cmd)
default:
return nil, fmt.Errorf("command '%s' would be executed with API", cmd.Type)
}
@@ -294,7 +304,7 @@ func (c *CLI) ExecuteUserCommand(cmd *Command) (ResponseIf, error) {
case "api_logout":
return c.Logout()
case "api_ping_server":
return c.PingByCommand(cmd)
return c.PingServerByCommand(cmd)
case "api_list_configs":
return c.ListConfigs(cmd)
case "api_set_log_level":

View File

@@ -109,7 +109,7 @@ func (c *CLI) LoginUserInteractive(email, password string) error {
return nil
}
func (c *CLI) PingByCommand(cmd *Command) (ResponseIf, error) {
func (c *CLI) PingServerByCommand(cmd *Command) (ResponseIf, error) {
iterations := 1
if iterationsParam, ok := cmd.Params["iterations"]; ok {
iterations = int(iterationsParam.(float64))

View File

@@ -335,6 +335,8 @@ func (l *Lexer) lookupIdent(ident string) Token {
return Token{Type: TokenMax, Value: ident}
case "STORE":
return Token{Type: TokenStore, Value: ident}
case "ENGINE":
return Token{Type: TokenEngine, Value: ident}
case "STREAM":
return Token{Type: TokenStream, Value: ident}
case "LS":
@@ -491,6 +493,8 @@ func (l *Lexer) lookupIdent(ident string) Token {
return Token{Type: TokenIngestors, Value: ident}
case "INGESTION":
return Token{Type: TokenIngestion, Value: ident}
case "CACHE":
return Token{Type: TokenCache, Value: ident}
case "MQ":
return Token{Type: TokenMQ, Value: ident}
case "PUBLISH":

View File

@@ -135,6 +135,7 @@ const (
TokenVector
TokenSize
TokenStore
TokenEngine
TokenName // For ALTER PROVIDER <name> NAME <new_name>
TokenBalance
TokenInstance
@@ -176,6 +177,7 @@ const (
TokenStart
TokenStop
TokenIngestion
TokenCache
TokenMQ
TokenPublish
TokenPull