cloudwego/volo

how to add custom field to S in volo-rust

captainjack0x7C8 opened this issue · 2 comments

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'.

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
  }
}

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
  }
}

thanks, i was misled by others before