Repository navigation
Go: update server config - #17027
Go: update server config#17027
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughThe change adds ingestor message-queue configuration, uses it during server startup, classifies Redis as a cache service, updates NATS status handling, and adds an OpenTelemetry enable flag with disabled default configuration. ChangesIngestor and service status updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/server/config.go (1)
434-442: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDelete the correct configuration key.
The key read from
configDicton line 435 is"mq_type", but the code attempts to delete"message_queue_type"on line 442. This leaves the original"mq_type"key in the dictionary.🐛 Proposed fix
configDict["extra"] = map[string]interface{}{ "message_queue_type": mqType, } - delete(configDict, "message_queue_type") + delete(configDict, "mq_type")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/server/config.go` around lines 434 - 442, In the “ingestor” configuration branch, update the delete call to remove the same “mq_type” key read by getString, while preserving its use as extra.message_queue_type.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/admin/service.go`:
- Around line 1027-1030: Update the "message_queue" case to replace the direct
assertions for configDict["host"] and configDict["port"] with comma-ok type
assertions, defaulting host and port to their zero values when keys are missing
or types differ, then pass those safe values to checkNatsAlive.
---
Outside diff comments:
In `@internal/server/config.go`:
- Around line 434-442: In the “ingestor” configuration branch, update the delete
call to remove the same “mq_type” key read by getString, while preserving its
use as extra.message_queue_type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e638065d-bcc4-4e64-a772-06704b70072f
📒 Files selected for processing (4)
cmd/ragflow_server.goconf/service_conf.yamlinternal/admin/service.gointernal/server/config.go
| case "message_queue": | ||
| switch name { | ||
| case "redis": | ||
| return s.getRedisInfo(name) | ||
| case "nats": | ||
| host := configDict["host"].(string) | ||
| port := configDict["port"].(int) | ||
| return s.checkNatsAlive(name, host, port) | ||
| default: | ||
| return map[string]interface{}{ | ||
| "service_name": name, | ||
| "status": "unknown", | ||
| "message": "Service type not supported", | ||
| }, nil | ||
| } | ||
| host := configDict["host"].(string) | ||
| port := configDict["port"].(int) | ||
| return s.checkNatsAlive(name, host, port) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Prevent panic from unsafe type assertions.
Direct type assertions on configDict will cause a runtime panic if the "host" or "port" keys are missing from the configuration (evaluating to nil), or if they are parsed as different types (e.g., if a missing port defaults to the string "-" during config init).
Since checkNatsAlive no longer actively uses these arguments internally, safely extract them using the comma-ok idiom to fall back to zero values and avoid crashing the request handler.
🔒️ Proposed fix
case "message_queue":
- host := configDict["host"].(string)
- port := configDict["port"].(int)
+ host, _ := configDict["host"].(string)
+ port, _ := configDict["port"].(int)
return s.checkNatsAlive(name, host, port)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case "message_queue": | |
| switch name { | |
| case "redis": | |
| return s.getRedisInfo(name) | |
| case "nats": | |
| host := configDict["host"].(string) | |
| port := configDict["port"].(int) | |
| return s.checkNatsAlive(name, host, port) | |
| default: | |
| return map[string]interface{}{ | |
| "service_name": name, | |
| "status": "unknown", | |
| "message": "Service type not supported", | |
| }, nil | |
| } | |
| host := configDict["host"].(string) | |
| port := configDict["port"].(int) | |
| return s.checkNatsAlive(name, host, port) | |
| case "message_queue": | |
| host, _ := configDict["host"].(string) | |
| port, _ := configDict["port"].(int) | |
| return s.checkNatsAlive(name, host, port) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/admin/service.go` around lines 1027 - 1030, Update the
"message_queue" case to replace the direct assertions for configDict["host"] and
configDict["port"] with comma-ok type assertions, defaulting host and port to
their zero values when keys are missing or types differ, then pass those safe
values to checkNatsAlive.
Summary