make redis_ctrl use conf

This commit is contained in:
Marc Planard 2023-06-04 15:03:09 +02:00
parent c5654c7ae0
commit 133f301d1c
3 changed files with 5 additions and 5 deletions

View File

@ -7,8 +7,8 @@ laser_id = 0
# Activate for more debug # Activate for more debug
debug = "true" debug = "true"
# Redis URL as IP:port # Redis URL as redis://IP:port/
redis_url = "127.0.0.1" redis_url = "redis://127.0.0.1:6379/"
# Either Helios or Etherdream # Either Helios or Etherdream
dac_family = "Helios" dac_family = "Helios"

View File

@ -37,7 +37,7 @@ fn run_all() -> Result<(), Box<dyn std::error::Error>> {
return Err(Box::new(LJError::ConfigFileMissing)); return Err(Box::new(LJError::ConfigFileMissing));
}; };
let config = Conf::new(&filename)?; let config = Conf::new(&filename)?;
let mut rs = RedisCtrl::new()?; let mut rs = RedisCtrl::new(&config.redis_url)?;
let running = Arc::new(AtomicBool::new(true)); let running = Arc::new(AtomicBool::new(true));
let r = running.clone(); let r = running.clone();

View File

@ -49,8 +49,8 @@ pub struct RedisCtrl {
} }
impl RedisCtrl { impl RedisCtrl {
pub fn new() -> Result<Self, Box<dyn std::error::Error>> { pub fn new(url: &str) -> Result<Self, Box<dyn std::error::Error>> {
let client = Client::open("redis://127.0.0.1/") let client = Client::open(url)
.map_err(LJError::RedisConnect)?; .map_err(LJError::RedisConnect)?;
let connection = client.get_connection() let connection = client.get_connection()
.map_err(LJError::RedisConnect)?; .map_err(LJError::RedisConnect)?;