Qovery/RedisLess

Use a Response enum

clarity0 opened this issue · 4 comments

Currently every response is formatted independently
I think it would be better to implement a struct to do this.

What do you mean by a "responder struct"?

pub enum RedisResponse {
    Integer(u32),
    SimpleString(String),
    BulkString(String),
    Array(Vec<RedisResponse>),
}

impl RedisResponse {
    fn respond(&self) -> Vec<u8>{
        match data {
            ...
        }
    }
}

Something like this, this way no matter what the response type is, the handling of the formatting of the response delegated to the Respond function and away from the logic of the commands.

I agree with that. It will be clearer for everyone