xtra icon indicating copy to clipboard operation
xtra copied to clipboard

Re-focus public API on `Address` & `Mailbox` aka short-lived `Context`

Open thomaseizinger opened this issue 3 years ago • 1 comments

As part of doing https://github.com/Restioson/xtra/pull/122, I started to form the following vision:

  • Chan should be the core channel implementation of the library, #122 gets us most of the way there
  • Sender and Receiver only really add an opinionated interfaces on top of it, plus reference counting
  • Neither Sender nor Receiver are publicly exposed, meaning I think they don't actually have to exist
  • Sender can be completely inlined into Address, removing an entire layer of indirection
  • Receiver can be promoted to a type called Mailbox that could be publicly exposed
  • Context would be something that is constructed only temporarily for the invocation of a handler (I think we discussed this idea at some point)

Putting all of this together, we could realise an API like this:

let (mailbox, address) = Mailbox::bounded(5);

tokio::spawn(xtra::run(mailbox, MyActor::new()));

With run being implemented more or less like what we have today.

thomaseizinger avatar Jul 14 '22 21:07 thomaseizinger

I think this makes sense!

Restioson avatar Jul 17 '22 16:07 Restioson