You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TheHelloServer is basiclly a proxy for the SingletonInstance, so the say_hi method need to call the same method on SingletonInstance.
What's the proper way to call SingletonInstance::say_hi ?
I created a tx(tokio::sync::mpsc) property on HelloServer, so the instance can use self.tx.send() to communicate with SingletonInstance.But HelloServer also need a receiver to get results. This seems too complicated.
The demo:
I made a simple demo https://github.com/divflex/demo-rpc
stackoverflow
https://stackoverflow.com/questions/76097231/tarpc-how-to-call-outer-structs-method
Question:
The
HelloServer
is basiclly a proxy for theSingletonInstance
, so thesay_hi
method need to call the same method onSingletonInstance
.What's the proper way to call
SingletonInstance::say_hi
?My idea:
Through messaging
https://github.com/divflex/demo-rpc/blob/ffe9dd49c0d2bcdf65771b00397e64473d7debfd/server/src/server.rs#L24
I created a
tx
(tokio::sync::mpsc
) property onHelloServer
, so the instance can useself.tx.send()
to communicate withSingletonInstance
.ButHelloServer
also need a receiver to get results. This seems too complicated.The second question
Is this part of code ok?
https://github.com/divflex/demo-rpc/blob/ffe9dd49c0d2bcdf65771b00397e64473d7debfd/server/src/server.rs#L33
The text was updated successfully, but these errors were encountered: