-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding healthcheck module with api and server status (#185)
* feat: Adding healthcheck module with api and server status * feat: Adding binary file info to healtcheck * feat: Restoring format to init and api modules (tabs, parenthesis)
- Loading branch information
Showing
3 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
local Server = require("codeium.api") | ||
|
||
local M = {} | ||
|
||
---@diagnostic disable-next-line: deprecated | ||
local start = vim.health.start or vim.health.report_start | ||
---@diagnostic disable-next-line: deprecated | ||
local ok = vim.health.ok or vim.health.report_ok | ||
local warn = vim.health.warn or vim.health.report_warn | ||
---@diagnostic disable-next-line: deprecated | ||
local error = vim.health.error or vim.health.report_error | ||
---@diagnostic disable-next-line: deprecated | ||
local info = vim.health.info or vim.health.report_info | ||
local health_logger = { ok = ok, info = info, warn = warn, error = error } | ||
|
||
local checkhealth = nil | ||
|
||
function M.check() | ||
start("Codeium: checking Codeium server status") | ||
local server_status = Server.check_status() | ||
if server_status.api_key_error ~= nil then | ||
error("API key not loaded: " .. server_status.api_key_error) | ||
else | ||
ok("API key properly loaded") | ||
end | ||
|
||
if checkhealth == nil then | ||
warn("Codeium: checkhealth is not set") | ||
return | ||
end | ||
checkhealth(health_logger) | ||
end | ||
|
||
function M.register(callback) | ||
checkhealth = callback | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters