how to add custom field to S in volo-rust
captainjack0x7C8 opened this issue · 2 comments
captainjack0x7C8 commented
Hi,i need to call redis or remote service at fn in struct S.
How to add redis or thrift clients to struct S as struct field, so that i can touch them by '&self'.
LYF1999 commented
Which struct S
do you mention?
if you are writing a Server, you can just
struct S {
redis: Redis,
}
impl xxxService for S {
fn xxx_method(&self, req: xxxReq) -> Result<xxxResponse> {
// call redis in here
}
}
captainjack0x7C8 commented
Which struct
S
do you mention? if you are writing a Server, you can juststruct S { redis: Redis, } impl xxxService for S { fn xxx_method(&self, req: xxxReq) -> Result<xxxResponse> { // call redis in here } }
thanks, i was misled by others before