feat: heartbeat check with log, sheet api config

Signed-off-by: Pakin <pakin.t@forth.co.th>
This commit is contained in:
Pakin 2026-05-09 11:02:02 +07:00
parent fa62d9d83f
commit d048dc2437
8 changed files with 751 additions and 21 deletions

View file

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{collections::HashMap, fs::File, io::BufReader};
use super::model::*;
use axum::extract::ws::{CloseFrame, Message, WebSocket};
@ -84,3 +84,23 @@ pub fn get_extra_parameters(s: String) -> HashMap<String, String> {
result
}
pub fn read_sheet_config() -> Result<Vec<String>, Box<dyn std::error::Error>> {
let mut res = Vec::new();
let config_file = File::open("./sheet-api.json")?;
let mut buf = BufReader::new(config_file);
let val: serde_json::Value = serde_json::from_reader(&mut buf)?;
if let Some(eobj) = val.get("endpoints")
&& let Some(endpoint_array) = eobj.as_array().clone()
{
res = endpoint_array
.iter()
.map(|x| x.as_str().unwrap_or_default().to_string())
.collect::<Vec<String>>();
}
Ok(res)
}