chore (backend-rs): cleanup
This commit is contained in:
parent
2884b2fb42
commit
28e2a24585
9 changed files with 14 additions and 12 deletions
|
@ -22,7 +22,7 @@ struct ServerConfig {
|
|||
pub proxy_bypass_hosts: Option<Vec<String>>,
|
||||
|
||||
pub allowed_private_networks: Option<Vec<String>>,
|
||||
/// `NapiValue` is not implemented for `u64`
|
||||
// TODO: i64 -> u64 (NapiValue is not implemented for u64)
|
||||
pub max_file_size: Option<i64>,
|
||||
pub access_log: Option<String>,
|
||||
pub cluster_limits: Option<WorkerConfigInternal>,
|
||||
|
@ -298,7 +298,7 @@ fn read_manifest() -> Manifest {
|
|||
}
|
||||
|
||||
#[crate::export]
|
||||
fn load_config() -> Config {
|
||||
pub fn load_config() -> Config {
|
||||
let server_config = read_config_file();
|
||||
let version = read_meta().version;
|
||||
let manifest = read_manifest();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::config::CONFIG;
|
||||
use once_cell::sync::OnceCell;
|
||||
use sea_orm::{ConnectOptions, Database, DbConn, DbErr};
|
||||
use tracing::log::LevelFilter;
|
||||
|
||||
static DB_CONN: once_cell::sync::OnceCell<DbConn> = once_cell::sync::OnceCell::new();
|
||||
static DB_CONN: OnceCell<DbConn> = OnceCell::new();
|
||||
|
||||
async fn init_database() -> Result<&'static DbConn, DbErr> {
|
||||
let database_uri = format!(
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::config::CONFIG;
|
||||
use once_cell::sync::OnceCell;
|
||||
use redis::{Client, Connection, RedisError};
|
||||
|
||||
static REDIS_CLIENT: once_cell::sync::OnceCell<Client> = once_cell::sync::OnceCell::new();
|
||||
static REDIS_CLIENT: OnceCell<Client> = OnceCell::new();
|
||||
|
||||
fn init_redis() -> Result<Client, RedisError> {
|
||||
let redis_url = {
|
||||
|
@ -26,7 +27,7 @@ fn init_redis() -> Result<Client, RedisError> {
|
|||
params.concat()
|
||||
};
|
||||
|
||||
tracing::info!("Initializing Redis connection");
|
||||
tracing::info!("Initializing Redis client");
|
||||
|
||||
Client::open(redis_url)
|
||||
}
|
||||
|
@ -38,8 +39,8 @@ pub fn redis_conn() -> Result<Connection, RedisError> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// prefix redis key
|
||||
#[inline]
|
||||
pub fn key(key: impl ToString) -> String {
|
||||
format!("{}:{}", CONFIG.redis_key_prefix, key.to_string())
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use sysinfo::System;
|
|||
|
||||
pub type SystemMutexError = PoisonError<MutexGuard<'static, System>>;
|
||||
|
||||
// TODO: handle this in more proper way when we move the entry point to backend-rs
|
||||
// TODO: handle this in a more proper way when we move the entry point to backend-rs
|
||||
pub fn system() -> Result<MutexGuard<'static, System>, SystemMutexError> {
|
||||
pub static SYSTEM: OnceLock<Mutex<System>> = OnceLock::new();
|
||||
SYSTEM.get_or_init(|| Mutex::new(System::new_all())).lock()
|
|
@ -1,2 +1,2 @@
|
|||
pub mod hardware_stats;
|
||||
pub mod log;
|
||||
pub mod server_stats;
|
||||
|
|
|
@ -4,7 +4,7 @@ use once_cell::sync::Lazy;
|
|||
use regex::Regex;
|
||||
use sea_orm::{prelude::*, QuerySelect};
|
||||
|
||||
/// TODO: handle name collisions better
|
||||
// TODO: handle name collisions in a better way
|
||||
#[crate::export(object, js_name = "NoteLikeForCheckWordMute")]
|
||||
pub struct NoteLike {
|
||||
pub file_ids: Vec<String>,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// TODO: handle name collisions better
|
||||
// TODO: handle name collisions in a better way
|
||||
#[crate::export(object, js_name = "NoteLikeForGetNoteSummary")]
|
||||
pub struct NoteLike {
|
||||
pub file_ids: Vec<String>,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::init::server_stats::{system, SystemMutexError};
|
||||
use crate::init::hardware_stats::{system, SystemMutexError};
|
||||
use sysinfo::{Disks, MemoryRefreshKind};
|
||||
|
||||
// TODO: i64 -> u64 (we can't export u64 to Node.js)
|
|
@ -7,6 +7,7 @@ pub mod escape_sql;
|
|||
pub mod format_milliseconds;
|
||||
pub mod get_image_size;
|
||||
pub mod get_note_summary;
|
||||
pub mod hardware_stats;
|
||||
pub mod is_safe_url;
|
||||
pub mod latest_version;
|
||||
pub mod mastodon_id;
|
||||
|
@ -15,4 +16,3 @@ pub mod nyaify;
|
|||
pub mod password;
|
||||
pub mod reaction;
|
||||
pub mod remove_old_attestation_challenges;
|
||||
pub mod server_stats;
|
||||
|
|
Loading…
Reference in a new issue