implement `Send` + `Sync` for `ServiceBusReceiver` and `ServiceBusReceiver`
Zizico2 opened this issue · 4 comments
Any chance ServiceBusSender
and ServiceBusReceiver
could be Sync
? Or should we just Arc<Mutex<>>
it? feels weird since there are already some Arc
s internally and I think this is a common enough requirement that the crate could support it (?). I could try to tackle this if it makes sense
And Clone
while where at it
Any chance ServiceBusSender and ServiceBusReceiver could be Sync?
I don't think so. The internal AMQP receiver needs to modify some states when receiving messages, and this ultimately comes to tokio::sync::mpsc::Receiver
which takes a &mut self
for the recv()
method (https://docs.rs/tokio/latest/tokio/sync/mpsc/struct.Receiver.html#method.recv).
Of course I could have use an Arc<Mutex<>>
internally, but that's hiding too much details of a potentially costly operation from the user.
Yep. Go ahead