Closed david415 closed 5 years ago
The service implementation object can be invoked from multiple threads (not in the default setup, but it is possible).
If you want to mutate data, you can guard the data with mutex:
struct MyServiceData {
...
}
struct MyServiceImpl {
data: Mutex<MyServiceData>,
}
impl MyService for MyServiceImpl {
fn call(&self, req: Req) -> Future<Resp> {
let data = self.data.lock().unwrap();
data.mutate()
}
}
The generated code doesn't seem to work for my use case since the grpc methods are called with &self instead of &mut self. However, I suspect plenty of other services besides mine will want to mutate state. Am I missing something?
here's my project branch attempting to use this library: https://github.com/katzenpost/multispool/tree/service_multi_spool.0