Hi,
On 19/01/2014 22:58, Michael Neumann wrote:
I think, if you add something like "Postpone(&mut Connection)" to the Value type
it could work.
Method tap would only be defined for type Value and will fails it it's value is
not Postpone.
Something like that:
That works if you always return value objects which I'm not doing. I return
actual rust types unwrapped because it gets too annoying otherwise.
impl Value {
fn tap(&self, fn callback) -> Connection {
match *self {
Postpone(conn) => { conn.add_callback(callback); conn }
_ => fail!()
}
}
}
Same thing here. The signature of the callback is different for each function
once you get rid of the concept of a value type.
Hm, in my rust-redis library, I just connect in redis::Client::new(). That's
pretty simple. What's the problem if each task just calls Client::new() instead
of get_connection()? If address resolution is your problem, I'd solve it
differently.
The problem with that is that each task will actually connect to the server. If
you have 10000 tasks that's 10000 connections to the server. My plan is to have
a connection pool on the client because of this and the tasks can fetch a
connection from there if one is available or will block until one becomes
available otherwise.
If there is no separate concept of a client then it has to be a global
connection pool which seems like a really bad idea.
Regards,
Armin
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev