feat: add gRPC client with config-based server address and album support
- Add tonic/prost gRPC client connecting to music-agregator service - Add config.yaml for configurable server host/port - Add build.rs for proto compilation from music-agregator - Update Artist/Album models to match proto with MonitorState enum - Convert album list from GetArtists response - Fix album click selection with correct layout offsets - Improve monitor state icons for better visibility
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Config {
|
||||
pub server: ServerConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ServerConfig {
|
||||
pub host: String,
|
||||
pub port: u16,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let contents = fs::read_to_string(path)?;
|
||||
let config: Config = serde_yaml::from_str(&contents)?;
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub fn grpc_addr(&self) -> String {
|
||||
format!("http://{}:{}", self.server.host, self.server.port)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user