Refactor for additional socktop connector library

- socktop connector allows you to communicate with socktop agent directly from you code without needing to implement the agent API directly.
- will also be used for non tui implementation of "socktop collector" in the future.
- moved to rust 2024 to take advantage of some new features that helped with refactor.
- fixed everything that exploded with update.
- added rust docs for lib.
This commit is contained in:
2025-09-04 05:30:25 -07:00
parent 622767a605
commit e51054811c
25 changed files with 823 additions and 229 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
name = "socktop_agent"
version = "1.40.67"
authors = ["Jason Witty <jasonpwitty+socktop@proton.me>"]
description = "Remote system monitor over WebSocket, TUI like top"
edition = "2021"
description = "Socktop agent daemon. Serves host metrics over WebSocket."
edition = "2024"
license = "MIT"
readme = "README.md"
+1 -1
View File
@@ -1,13 +1,13 @@
fn main() {
// Vendored protoc for reproducible builds
let protoc = protoc_bin_vendored::protoc_bin_path().expect("protoc");
std::env::set_var("PROTOC", &protoc);
println!("cargo:rerun-if-changed=proto/processes.proto");
// Compile protobuf definitions for processes
let mut cfg = prost_build::Config::new();
cfg.out_dir(std::env::var("OUT_DIR").unwrap());
cfg.protoc_executable(protoc); // Use the vendored protoc directly
// Use local path (ensures file is inside published crate tarball)
cfg.compile_protos(&["proto/processes.proto"], &["proto"]) // relative to CARGO_MANIFEST_DIR
.expect("compile protos");
+1 -1
View File
@@ -8,7 +8,7 @@ mod state;
mod types;
mod ws;
use axum::{http::StatusCode, routing::get, Router};
use axum::{Router, http::StatusCode, routing::get};
use std::net::SocketAddr;
use std::str::FromStr;
+1 -1
View File
@@ -1,8 +1,8 @@
//! Shared agent state: sysinfo handles and hot JSON cache.
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::time::{Duration, Instant};
use sysinfo::{Components, Disks, Networks, System};
use tokio::sync::Mutex;
+1 -1
View File
@@ -5,7 +5,7 @@ use axum::{
extract::{Query, State, WebSocketUpgrade},
response::Response,
};
use flate2::{write::GzEncoder, Compression};
use flate2::{Compression, write::GzEncoder};
use futures_util::StreamExt;
use once_cell::sync::OnceCell;
use std::collections::HashMap;