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
debug = "true"
# Redis URL as IP:port
redis_url = "127.0.0.1"
# Redis URL as redis://IP:port/
redis_url = "redis://127.0.0.1:6379/"
# Either Helios or Etherdream
dac_family = "Helios"

View File

@ -37,7 +37,7 @@ fn run_all() -> Result<(), Box<dyn std::error::Error>> {
return Err(Box::new(LJError::ConfigFileMissing));
};
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 r = running.clone();

View File

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