Skip to content

User callbacks for send failures#61

Merged
satyamjay-iitd merged 3 commits intomasterfrom
callbacks
Oct 21, 2025
Merged

User callbacks for send failures#61
satyamjay-iitd merged 3 commits intomasterfrom
callbacks

Conversation

@Brian-1402
Copy link
Collaborator

@Brian-1402 Brian-1402 commented Sep 24, 2025

Notes to resolve:

  • Had to add E::Error: Send + 'static in multiple places in actor/src/send.rs to resolve the error of:
    <E as tokio_util::codec::Encoder<M>>::Error cannot be sent between threads safely
    
    But I'm still not sure what caused this error in the first place.
  • For Retry, msg gets cloned even for successful sends. Bad for efficiency.
    • But confused how to resolve, coz how to predict whether the msg send will succeed or not? If send fails, then the initial attempt shouldn't have consumed msg coz now msg cannot be recovered to use in retry.
    • Can use Arc, but unsure of the decision for Arc overhead for every single msg sent.
    • Solved: recover the sent failed msg from Result::Error response
  • Retry can be extended to also include timeout delay
    • Done.

Other decisions:

  • Default choice is Retry 5 times with 100 ms delay.
  • Callback choice affects both msg send failure and actor resolve failure.

Closes #56

@Brian-1402 Brian-1402 self-assigned this Sep 24, 2025
@satyamjay-iitd
Copy link
Owner

satyamjay-iitd commented Sep 27, 2025

  1. Error can be Send + 'static, its fine.
  2. You dont need to clone; The error that is returned returns the message that you tried to send. https://docs.rs/tokio/latest/tokio/sync/mpsc/struct.Sender.html#method.send
  3. Add it in the enum and leave todo!() in the handler

@Brian-1402
Copy link
Collaborator Author

Brian-1402 commented Sep 27, 2025

  1. You dont need to clone; The error that is returned returns the message that you tried to send. https://docs.rs/tokio/latest/tokio/sync/mpsc/struct.Sender.html#method.send

Cool this seems to work for local sender, but I'm confused for remote sender (FramedWrite). Apparently it depends on the encoder to make the msg recoverable? Is adding a trait impl for the encoder to recover msg the right direction? @satyamjay-iitd

@satyamjay-iitd satyamjay-iitd merged commit 224468d into master Oct 21, 2025
1 check passed
@satyamjay-iitd satyamjay-iitd deleted the callbacks branch October 21, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User callbacks

2 participants