fix: 修复若干问题,添加java lsp
This commit is contained in:
@@ -22,10 +22,17 @@ type SessionStatsProvider interface {
|
||||
ActiveSessions() map[string]int
|
||||
}
|
||||
|
||||
// LSPStatusProvider 暴露按语言的 LSP 探测状态。
|
||||
type LSPStatusProvider interface {
|
||||
LspServiceStatus() map[string]any
|
||||
}
|
||||
|
||||
// RouteOptions 控制 HTTP/WS 接口的超时与请求体上限。
|
||||
type RouteOptions struct {
|
||||
RequestTimeout time.Duration // 单次补全调用超时时间。
|
||||
MaxBodyBytes int64 // 请求体最大字节数(HTTP/WS 共用)。
|
||||
// LSPStatusProvider 可选,用于输出语言服务在线状态。
|
||||
LSPStatusProvider LSPStatusProvider
|
||||
}
|
||||
|
||||
// RegisterRoutes 注册健康检查、HTTP 补全接口和 WebSocket 补全接口。
|
||||
@@ -41,6 +48,7 @@ func RegisterRoutes(router *gin.Engine, service CompletionService, options ...Ro
|
||||
if options[0].MaxBodyBytes > 0 {
|
||||
opts.MaxBodyBytes = options[0].MaxBodyBytes
|
||||
}
|
||||
opts.LSPStatusProvider = options[0].LSPStatusProvider
|
||||
}
|
||||
|
||||
router.GET("/health", func(c *gin.Context) {
|
||||
@@ -62,6 +70,17 @@ func RegisterRoutes(router *gin.Engine, service CompletionService, options ...Ro
|
||||
})
|
||||
})
|
||||
|
||||
router.GET("/health/lsp-status", func(c *gin.Context) {
|
||||
languages := map[string]any{}
|
||||
if opts.LSPStatusProvider != nil {
|
||||
languages = opts.LSPStatusProvider.LspServiceStatus()
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "ok",
|
||||
"languages": languages,
|
||||
})
|
||||
})
|
||||
|
||||
registerWSRoutes(router, service, opts)
|
||||
|
||||
handleCompletion := func(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user