-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an Actor
custom derive macro
#163
Conversation
Actor
custom deriveActor
custom derive macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change in concept, but I do wonder if this is the most optimal directory structure/layout. I see that https://github.com/tokio-rs/tokio has a separate directory for the main tokio crate, whereas this has the crate root as .
. This also doesn't use a workspace, I think.
We do use a workspace here, it is defined in the main crate! I don't care much about the structure but if we want to change it, I'd suggest a different PR because it will be quite the diff noise :) |
Oh, I hadn't seen that! |
commit 9cb6544 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 31 20:09:45 2022 +0200 Simplify visibility Mailbox is not yet a public type so we don't need to say pub(super). commit f7debd3 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 31 20:09:27 2022 +0200 Merge impl blocks commit ed9f4d1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 31 20:06:53 2022 +0200 Squashed commit of the following: commit a0f1dfe Merge: d63a549 100195d Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:45:39 2022 +0200 Merge branch 'master' into generic-refcounter commit d63a549 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:58:53 2022 +0200 Fix invalid doc link commit 0eca513 Merge: 1ea9670 89ac7bb Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:57:20 2022 +0200 Merge branch 'master' into generic-refcounter commit 1ea9670 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:54:04 2022 +0200 Express conversion to `Either` via `Into` bound This avoids an unreachable clause where `Rc` could not be converted into an `Either` type. commit 128e655 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:54:15 2022 +0200 Make impl resilient against moves commit 4c87c84 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:52:13 2022 +0200 Hide impl details of pointer debug output commit 6ddb280 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:45:29 2022 +0200 Fix build error commit 36921d4 Merge: 4449c33 f169e6d Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:44:53 2022 +0200 Merge branch 'master' into generic-refcounter commit 4449c33 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:44:13 2022 +0200 Undo renaming We are calling this on a generic Rc but the return type is not generic enough. commit 2bd2be1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:40:38 2022 +0200 Reduce diff to master commit 40fd855 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:29:27 2022 +0200 Introduce `RefCounter::into_either` This allows us to access `Address::to_either` when abstracting over strong/weak reference counts. commit 5cd6c29 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Aug 15 22:03:59 2022 +0200 Seal `RefCounter` trait This allows us to export it without being worried about users depending on its actual design. commit 5547c9f Author: Thomas Eizinger <thomas@eizinger.io> Date: Sat Aug 6 00:17:30 2022 +0200 Add more docs commit 73ef566 Author: Thomas Eizinger <thomas@eizinger.io> Date: Sat Aug 6 00:05:50 2022 +0200 Fix docs commit db08146 Author: Thomas Eizinger <thomas@eizinger.io> Date: Sat Aug 6 00:00:10 2022 +0200 Promote `inbox::rx` to `Mailbox` type This type is a counter-part to `Address` and will be public at some point in the future. commit 9ed521b Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:56:46 2022 +0200 Use `ChanPtr` inside `ReceiveFuture` commit 47d6092 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:42:41 2022 +0200 Re-order functions to be in meaningful order commit f6e8365 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:36:00 2022 +0200 Use short initializer commit dcea698 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:34:29 2022 +0200 Add docs to `RefCounter` trait commit 3b4725e Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:27:11 2022 +0200 Encapsulate reference counting policy logic on `Chan` commit ed46b76 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:59:37 2022 +0200 Add docs commit 517fd16 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:57:12 2022 +0200 Don't export `RefCounter` Not exporting it allows us to avoid sealing the trait because if users cannot name the type, the cannot call functions or implement it on types. commit 45941be Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:47:47 2022 +0200 Go back to `Rc` naming for type parameter commit 08242a5 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:42:49 2022 +0200 Remove double increment commit e7252c3 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 17:47:18 2022 +0200 Rename `RefCountPolicy` to `RefCounter` The old name was good enough and we don't need to cause unnecessary diff. commit d29c37b Merge: e1ae74e 17cfd3a Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 17:46:20 2022 +0200 Merge branch 'master' into generic-refcounter commit e1ae74e Merge: 7e275b3 b8cb4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 17:36:10 2022 +0200 Merge branch 'master' into generic-refcounter commit 7e275b3 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:33:23 2022 +0200 Add test for width of pointer commit 78f5e4f Merge: faa48f8 8a85729 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:26:11 2022 +0200 Merge branch 'master' into generic-refcounter commit faa48f8 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:09:46 2022 +0200 Remove `Sender` This is an unnecessary layer now. commit 4cb448d Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:04:07 2022 +0200 Implement fmt::Debug for ChanPtr commit b653f8d Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 22:56:20 2022 +0200 Make `chan_ptr` module private commit 862e9fa Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 20:31:19 2022 +0200 Fix clippy commit fbf5e5a Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 20:15:19 2022 +0200 Temporarily fix tests commit 8781f15 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 25 12:05:20 2022 +0200 PoC for generic ref counter commit 1423520 Merge: d33b741 100195d Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:50:05 2022 +0200 Merge branch 'master' into unify-recv-future commit 100195d Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:42:31 2022 +0200 Simplify conditional code around instrumentation feature (#172) By splitting things into modules with identical APIs, we can remove a lot of `cfg(feature)` attributes. commit d33b741 Merge: 158a1c8 89ac7bb Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:09:11 2022 +0200 Merge branch 'master' into unify-recv-future commit 89ac7bb Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:46:06 2022 +0200 Differentiate single and broadcast message on type-system level (#166) Prior to this patch-set, we had constructs like `MessageType` and `SentMessage`. These were used to write code that is generic over a particular message type. In reality however, we don't actually need to differentiate between these cases because the codepaths for each type are statically known in all cases. Unfortunately, introducing an actual split introduced a bit more code (net ~ 70 lines) but in exchange, we remove a few `unreachable` error clauses and make it overall easier to follow the dataflow through xtra's channel implementation. commit e6941e2 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 13:53:08 2022 +0200 Update feature list (#178) commit bcfd20c Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Aug 18 02:15:33 2022 +1000 Remove irrelevant changelog entry commit f169e6d Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:51:29 2022 +0200 Fix `scoped_actor_task` example (#175) Because of an unknown feature, this example was not compiled as part of our CI run and we missed it while moving to the new spawn API. commit 358480c Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:51:14 2022 +0200 Remove `global_spawner_ext` example (#177) This is the same as the `basic_smol` example. commit cf613fa Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:33:09 2022 +0200 Enforce grouping of imports per module (#174) Most of our codebase seems to be formatted this way, we can enforce this with a rustfmt setting. commit 41bc8db Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:32:36 2022 +0200 Simplify example in README (#173) commit aa923d0 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 13:32:59 2022 +0200 Add test for public API of `Address<A, Rc>` (#171) commit 4940e9a Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:28:45 2022 +0200 Add `public_api` test (#169) commit 1a859b6 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 12 10:54:05 2022 +0200 Add an `Actor` custom derive macro (#163) * Add basic implementation of `Actor` custom derive This is located within in the xtra-macros subcrate. The top level crate also is now a workspace. commit 4d4d4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 10 14:34:17 2022 +0200 Refactor instrumentation tests (#165) * Re-order elements in `instrumentation` test by priority 1. Tests come first 2. Actors second 3. Test infrastructure last * Remove unnecessary `pub` qualifier * Rename `MockWriter` to `BufferWriter` Given that we write to a buffer, this is a more appropiate name. * Introduce `Buffer` to allow for direct comparison with `[&str, N]` * Construct `BufferWriter` in `get_subscriber` This reduced some duplication in the tests. commit 6ca3382 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 10 14:19:28 2022 +0200 Simplify control-flow in `ChanInner::pop_` functions (#167) Previously, we first checked whether the corresponding queue WILL have space if we now pop a message. This is functionally equivalent to _trying_ to pop a message, exiting early if we can't (using `?`) and then adding another message to the queue if we now have space. Checking for space is equivalent to the queue not being full and we already have helper functions for this. commit 17cfd3a Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 13:01:58 2022 +0200 Have `Sender` deref to `Chan` (#161) Essentially, `Sender` is a smart-pointer to `Chan` with custom reference counting logic and thus it makes sense for it to implement `Deref`. Most of the functionality accessed by other modules lives on `Chan`. commit 158a1c8 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 20:27:18 2022 +0200 Don't implement `Deref` on `Receiver` If we have to wrap it to provide functionality, it is not a smart-pointer. commit 3dd7075 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 20:11:58 2022 +0200 Have `Receiver` have a public API again commit aad40ff Merge: 422956f b8cb4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 19:58:52 2022 +0200 Merge branch 'master' into unify-recv-future commit b8cb4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 11:51:50 2022 +0200 Remove generic ref-counting from `Receiver` (#160) * Remove `RxWeak` We never have a reference to a weak mailbox of the actor. * Remove ref-counter concept from `Receiver` We don't need to delegate to anything if there is only one way of ref-counting. * Inline shutdown of waiting senders into decrement function This applies the "Tell; don't ask" principle. commit f8b61bd Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 11:49:51 2022 +0200 Remove duplicated code for popping from broadcast channel (#155) * Extract utility function for longest broadcast queue This brings the `try_advance_broadcast_tail` fn more in line with the other `pop_` function in terms of internal structure. * Introduce `pop_broadcast` on `ChanInner` This creates consistency with `pop_ordered` and `pop_priority`. * Move locking of `inner` to top of function To achieve similar APIs between the different mailboxes, we lock the broadcast mailbox multiple times in the process of dealing with it. To still avoid race conditions, we need to lock `ChanInner` as early as possible because the broadcast mailbox is also only modified with `ChanInner` being locked. commit 422956f Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:22:33 2022 +0200 Remove references to private futures They don't seem to resolve unfortunately :( commit 360f022 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:15:53 2022 +0200 Revert to actually mentioning self type commit 7c1aa3c Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:12:19 2022 +0200 Inline `next_broadcast_message` commit d271eae Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:10:37 2022 +0200 Remove unnecessary `Rc` type parameter commit aeebf60 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:09:34 2022 +0200 Remove unnecessary `Rc` argument from `Waiting` commit b9a338a Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:07:56 2022 +0200 Add more docs to internal futures commit 64518d6 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:06:49 2022 +0200 Align variant name with `Sending` future commit 727c4ec Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:06:05 2022 +0200 Move `ReceiveFuture` from `rx` into `recv_future` module commit dee03f7 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 13:56:26 2022 +0200 Move priority to dedicated module commit 452db5e Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 13:38:21 2022 +0200 Move `ReceiveFuture` into separate top-level module commit 8a85729 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Jul 26 14:46:15 2022 +0100 Redesign xtra's spawn API (#156) * Redesign xtra's spawn API This removes `Actor::create`, `ActorManager` and the various runtime extension traits in favor of top-level free functions for spawning an actor instance into a specific runtime. This is deemed to be more ergonomic because: - Users do not need to import an extension trait for their runtime - Users do not need to import the `Actor` trait to run it which was otherwise required to call `create`. - The implementation has less indirection, thus making it easier for users to understand and perhaps adapt / write their own `spawn` fn depending on their needs. The implementation is not strictly functionally equivalent to what we had before. In particular, we no longer support spawning in a runtime handle of the tokio and smol runtimes. We accept this regression because we assume that it is a niche usecase and the now easier implementation should showcase users, how they can easily write themselves a helper function that spawns an actor using a runtime handle in a single line of code. In other words, the `spawn` API of xtra is purposely design to make 80% of usecases work. For everything else, users should write their own `spawn` function. Closes #136. commit 285b3e9 Author: Restioson <restiosondev@gmail.com> Date: Fri Jul 22 16:03:28 2022 +0200 Use or_current when creating spans (#154) * Use or_current when creating spans This makes sure that if the xtra_actor_request is disabled, the other spans and child-spans of xtra_message_handler will be children of the would-be parent of xtra_actor_request, rather than being parentless, top-level spans. * Add test for or_current commit 3d063ff Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 22 11:50:53 2022 +0100 Move capacity from `Chan` to `ChanInner` (#150) This allows us to avoid some back and forth passing of data which makes a few functions have less arguments and overall better ergonomics. commit 4b5f8af Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 21 23:27:05 2022 +0100 Encapsulate more functionality in `WaitingReceiver` (#149) * Make `WakeReason` an implementation detail of `WaitingReceiver` We can achieve this by having more specific functions on `WaitingReceiver` itself. * Introduce `FulfillHandle` for `WaitingReceiver` Previously, the references to `WaitingReceiver` were stored "naked" within the channel and the `Future` implementation. This made it hard to understand that there are only ever two references. This patch introduces those two references as proper types and adds documentation on how the `WaitingReceiver` works. * Store cancellation state in boolean flag This avoids an "unreachable" branch when polling the receiver. * Make `WakeReason` an implementation detail of `WaitingReceiver` We can achieve this by making a custom `poll` function on `WaitingReceiver` and passing `Receiver` as a reference in. * Make `WakeReason` private This is possible, now that we made it an implementation detail of `WaitingReceiver`. * Move `WaitingReceiver` to its own module This component houses a good chunk of functionality now and is better understood in isolation. Additionally, this allows us to better enforce visibility of types. * Introduce dedicated `Waiting` sub-state This allows for a more focused `Drop` implementation. * Use `catty` to implement `WaitingReceiver` (#151) Now that the waker management is encapsulated in catty, `WakeReason` is no longer an accurate name. `CtrlMsg` seems better. Additionally, instead of "fulfilling" the waiting receiver, the language of "notifying" feels more natural. * Remove dependency on catty patch (#153) * Remove dependency on catty patch Co-authored-by: Restioson <restiosondev@gmail.com> * Update src/inbox.rs Co-authored-by: Restioson <restiosondev@gmail.com> commit eab4691 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 21 22:24:42 2022 +0100 Update `with-tracing-0_1` feature docs to `instrumentation` feature (#152) * Remove mention of outdated feature * Mention `instrumentation` feature commit eafe175 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Jul 19 13:09:14 2022 +0100 Unify message sending into one `SendFuture` (#147) * Have `SendFuture` handle every case of sending messages This one future now handles: - Sending a single message with the actor type being named - Sending a single message with the actor type being erased - Sending a broadcast message with the actor type being named * Add SendFuture::broadcast_erased Using this function takes a few more changes but it is added here because it will definitely be useful later. * Employ "double result" pattern for `try_send` Using a double result is useful in cases where the errors returned by a function fall into two categories: recoverable and non-recoverable. A disconnected channel is not recoverable and we can thus directly forward it with `?`. The mailbox being full is something we need to deal with in `SendFuture` which is why it is within another layer of `Result`. commit ff782ad Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 18:52:27 2022 +0100 Don't pass message name into envelope (#148) * Don't pass message name into envelope An envelope knows which message it is carrying, no need to pass it in. * Remove `MessageKind` Without the additional field for the message's name, this layer does not serve any purpose. commit 910f3fb Author: Restioson <restiosondev@gmail.com> Date: Mon Jul 18 17:35:52 2022 +0200 Strip span fields from waiting and handler spans (#145) Currently, these are always children of the request span, so adding them as fields in them too is redundant. It would be a simplification to move this just to xtra_message_handler, but this is unfortunately not possible in the case of a disconnected actor which will never handle the message - this would miss all actor and message type information. commit a0c1ad6 Author: Restioson <restiosondev@gmail.com> Date: Mon Jul 18 14:05:29 2022 +0200 Improve span variables in tracing spans (#143) * Rename message -> message_type Weird behaviour is exhibited by some subscribers with `message` as a field name, probably since it is reserved, so `message_type` is used instead. "actor" was also renamed "actor_type" for consistency. Also, the display implementation of type name strings are used to avoid unnecessary quotes in the output. commit a2bedd5 Author: Restioson <restiosondev@gmail.com> Date: Mon Jul 18 13:05:57 2022 +0200 Create spans late (#120) Create the actor request span after first poll of `send` in order to ensure `send(...).instrument(...)` works as expected. commit 7b0b6ea Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 09:53:35 2022 +0100 Always store message priority in envelope (#142) * Always store message priority in envelope Previously, we only stored the priority of broadcast messages in the envelope. For regular messages, the priority was stored outside in a wrapper struct. This disparity is hard to understand as there is no apparent reason why the priority could not be stored in the message envelope. With this patch, we move the priority into the message envelope and also expose a `set_priority` function for each envelope type which allows us to consolidate the way we set priority from the `SendFuture`. To allow this, message envelopes need to be employ interior mutability (they are either box'ed or arc'ed). We use a spin lock which should basically be free. A `SendFuture` cannot be cloned and thus will never be accessed from two different threads, meaning the lock will never be congested. commit fd3c282 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 09:41:54 2022 +0100 Remove `ReceiveFuture::cancel` in favor of cancellation-safety docs (#138) Remove `ReceiveFuture::cancel` in favor of cancellation-safety docs, which fixes #134. Tests were added to check behaviour of resending messages on drop. commit 07e4664 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 09:10:48 2022 +0100 Introduce optional `sink` feature (#140) * Introduce optional `sink` feature Not every user may need the `sink` feature and we can minimise our dependency tree in those cases. * Extend README docs * Fix docs commit bc7808c Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 07:07:45 2022 +0100 Move channel logic into `Chan` (#122) Move the channel logic (e.g try_send and try_recv) into Chan itself. The goal was is follows: - Have Chan house the core channel implementation with descriptive function names for key operations - Have Sender and Receiver be thin layers on top that combine Chan with reference counting and provide a Future-based APIs for sending and receiving commit e54b413 Author: Restioson <restiosondev@gmail.com> Date: Sun Jul 17 20:52:20 2022 +0200 Annotate TickFuture with must_use (#139) This is since it is a future
commit 9cb6544 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 31 20:09:45 2022 +0200 Simplify visibility Mailbox is not yet a public type so we don't need to say pub(super). commit f7debd3 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 31 20:09:27 2022 +0200 Merge impl blocks commit ed9f4d1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 31 20:06:53 2022 +0200 Squashed commit of the following: commit a0f1dfe Merge: d63a549 100195d Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:45:39 2022 +0200 Merge branch 'master' into generic-refcounter commit d63a549 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:58:53 2022 +0200 Fix invalid doc link commit 0eca513 Merge: 1ea9670 89ac7bb Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:57:20 2022 +0200 Merge branch 'master' into generic-refcounter commit 1ea9670 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:54:04 2022 +0200 Express conversion to `Either` via `Into` bound This avoids an unreachable clause where `Rc` could not be converted into an `Either` type. commit 128e655 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:54:15 2022 +0200 Make impl resilient against moves commit 4c87c84 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:52:13 2022 +0200 Hide impl details of pointer debug output commit 6ddb280 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:45:29 2022 +0200 Fix build error commit 36921d4 Merge: 4449c33 f169e6d Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 17:44:53 2022 +0200 Merge branch 'master' into generic-refcounter commit 4449c33 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:44:13 2022 +0200 Undo renaming We are calling this on a generic Rc but the return type is not generic enough. commit 2bd2be1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:40:38 2022 +0200 Reduce diff to master commit 40fd855 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:29:27 2022 +0200 Introduce `RefCounter::into_either` This allows us to access `Address::to_either` when abstracting over strong/weak reference counts. commit 5cd6c29 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Aug 15 22:03:59 2022 +0200 Seal `RefCounter` trait This allows us to export it without being worried about users depending on its actual design. commit 5547c9f Author: Thomas Eizinger <thomas@eizinger.io> Date: Sat Aug 6 00:17:30 2022 +0200 Add more docs commit 73ef566 Author: Thomas Eizinger <thomas@eizinger.io> Date: Sat Aug 6 00:05:50 2022 +0200 Fix docs commit db08146 Author: Thomas Eizinger <thomas@eizinger.io> Date: Sat Aug 6 00:00:10 2022 +0200 Promote `inbox::rx` to `Mailbox` type This type is a counter-part to `Address` and will be public at some point in the future. commit 9ed521b Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:56:46 2022 +0200 Use `ChanPtr` inside `ReceiveFuture` commit 47d6092 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:42:41 2022 +0200 Re-order functions to be in meaningful order commit f6e8365 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:36:00 2022 +0200 Use short initializer commit dcea698 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:34:29 2022 +0200 Add docs to `RefCounter` trait commit 3b4725e Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 23:27:11 2022 +0200 Encapsulate reference counting policy logic on `Chan` commit ed46b76 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:59:37 2022 +0200 Add docs commit 517fd16 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:57:12 2022 +0200 Don't export `RefCounter` Not exporting it allows us to avoid sealing the trait because if users cannot name the type, the cannot call functions or implement it on types. commit 45941be Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:47:47 2022 +0200 Go back to `Rc` naming for type parameter commit 08242a5 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 22:42:49 2022 +0200 Remove double increment commit e7252c3 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 17:47:18 2022 +0200 Rename `RefCountPolicy` to `RefCounter` The old name was good enough and we don't need to cause unnecessary diff. commit d29c37b Merge: e1ae74e 17cfd3a Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 17:46:20 2022 +0200 Merge branch 'master' into generic-refcounter commit e1ae74e Merge: 7e275b3 b8cb4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 17:36:10 2022 +0200 Merge branch 'master' into generic-refcounter commit 7e275b3 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:33:23 2022 +0200 Add test for width of pointer commit 78f5e4f Merge: faa48f8 8a85729 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:26:11 2022 +0200 Merge branch 'master' into generic-refcounter commit faa48f8 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:09:46 2022 +0200 Remove `Sender` This is an unnecessary layer now. commit 4cb448d Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 23:04:07 2022 +0200 Implement fmt::Debug for ChanPtr commit b653f8d Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 22:56:20 2022 +0200 Make `chan_ptr` module private commit 862e9fa Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 20:31:19 2022 +0200 Fix clippy commit fbf5e5a Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 28 20:15:19 2022 +0200 Temporarily fix tests commit 8781f15 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 25 12:05:20 2022 +0200 PoC for generic ref counter commit 1423520 Merge: d33b741 100195d Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:50:05 2022 +0200 Merge branch 'master' into unify-recv-future commit 100195d Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:42:31 2022 +0200 Simplify conditional code around instrumentation feature (#172) By splitting things into modules with identical APIs, we can remove a lot of `cfg(feature)` attributes. commit d33b741 Merge: 158a1c8 89ac7bb Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 16:09:11 2022 +0200 Merge branch 'master' into unify-recv-future commit 89ac7bb Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 15:46:06 2022 +0200 Differentiate single and broadcast message on type-system level (#166) Prior to this patch-set, we had constructs like `MessageType` and `SentMessage`. These were used to write code that is generic over a particular message type. In reality however, we don't actually need to differentiate between these cases because the codepaths for each type are statically known in all cases. Unfortunately, introducing an actual split introduced a bit more code (net ~ 70 lines) but in exchange, we remove a few `unreachable` error clauses and make it overall easier to follow the dataflow through xtra's channel implementation. commit e6941e2 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 30 13:53:08 2022 +0200 Update feature list (#178) commit bcfd20c Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Aug 18 02:15:33 2022 +1000 Remove irrelevant changelog entry commit f169e6d Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:51:29 2022 +0200 Fix `scoped_actor_task` example (#175) Because of an unknown feature, this example was not compiled as part of our CI run and we missed it while moving to the new spawn API. commit 358480c Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:51:14 2022 +0200 Remove `global_spawner_ext` example (#177) This is the same as the `basic_smol` example. commit cf613fa Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:33:09 2022 +0200 Enforce grouping of imports per module (#174) Most of our codebase seems to be formatted this way, we can enforce this with a rustfmt setting. commit 41bc8db Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 17 10:32:36 2022 +0200 Simplify example in README (#173) commit aa923d0 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 13:32:59 2022 +0200 Add test for public API of `Address<A, Rc>` (#171) commit 4940e9a Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 16 11:28:45 2022 +0200 Add `public_api` test (#169) commit 1a859b6 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 12 10:54:05 2022 +0200 Add an `Actor` custom derive macro (#163) * Add basic implementation of `Actor` custom derive This is located within in the xtra-macros subcrate. The top level crate also is now a workspace. commit 4d4d4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 10 14:34:17 2022 +0200 Refactor instrumentation tests (#165) * Re-order elements in `instrumentation` test by priority 1. Tests come first 2. Actors second 3. Test infrastructure last * Remove unnecessary `pub` qualifier * Rename `MockWriter` to `BufferWriter` Given that we write to a buffer, this is a more appropiate name. * Introduce `Buffer` to allow for direct comparison with `[&str, N]` * Construct `BufferWriter` in `get_subscriber` This reduced some duplication in the tests. commit 6ca3382 Author: Thomas Eizinger <thomas@eizinger.io> Date: Wed Aug 10 14:19:28 2022 +0200 Simplify control-flow in `ChanInner::pop_` functions (#167) Previously, we first checked whether the corresponding queue WILL have space if we now pop a message. This is functionally equivalent to _trying_ to pop a message, exiting early if we can't (using `?`) and then adding another message to the queue if we now have space. Checking for space is equivalent to the queue not being full and we already have helper functions for this. commit 17cfd3a Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Aug 5 13:01:58 2022 +0200 Have `Sender` deref to `Chan` (#161) Essentially, `Sender` is a smart-pointer to `Chan` with custom reference counting logic and thus it makes sense for it to implement `Deref`. Most of the functionality accessed by other modules lives on `Chan`. commit 158a1c8 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 20:27:18 2022 +0200 Don't implement `Deref` on `Receiver` If we have to wrap it to provide functionality, it is not a smart-pointer. commit 3dd7075 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 20:11:58 2022 +0200 Have `Receiver` have a public API again commit aad40ff Merge: 422956f b8cb4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 19:58:52 2022 +0200 Merge branch 'master' into unify-recv-future commit b8cb4c1 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 11:51:50 2022 +0200 Remove generic ref-counting from `Receiver` (#160) * Remove `RxWeak` We never have a reference to a weak mailbox of the actor. * Remove ref-counter concept from `Receiver` We don't need to delegate to anything if there is only one way of ref-counting. * Inline shutdown of waiting senders into decrement function This applies the "Tell; don't ask" principle. commit f8b61bd Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Aug 2 11:49:51 2022 +0200 Remove duplicated code for popping from broadcast channel (#155) * Extract utility function for longest broadcast queue This brings the `try_advance_broadcast_tail` fn more in line with the other `pop_` function in terms of internal structure. * Introduce `pop_broadcast` on `ChanInner` This creates consistency with `pop_ordered` and `pop_priority`. * Move locking of `inner` to top of function To achieve similar APIs between the different mailboxes, we lock the broadcast mailbox multiple times in the process of dealing with it. To still avoid race conditions, we need to lock `ChanInner` as early as possible because the broadcast mailbox is also only modified with `ChanInner` being locked. commit 422956f Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:22:33 2022 +0200 Remove references to private futures They don't seem to resolve unfortunately :( commit 360f022 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:15:53 2022 +0200 Revert to actually mentioning self type commit 7c1aa3c Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:12:19 2022 +0200 Inline `next_broadcast_message` commit d271eae Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:10:37 2022 +0200 Remove unnecessary `Rc` type parameter commit aeebf60 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:09:34 2022 +0200 Remove unnecessary `Rc` argument from `Waiting` commit b9a338a Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:07:56 2022 +0200 Add more docs to internal futures commit 64518d6 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:06:49 2022 +0200 Align variant name with `Sending` future commit 727c4ec Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 14:06:05 2022 +0200 Move `ReceiveFuture` from `rx` into `recv_future` module commit dee03f7 Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 13:56:26 2022 +0200 Move priority to dedicated module commit 452db5e Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 29 13:38:21 2022 +0200 Move `ReceiveFuture` into separate top-level module commit 8a85729 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Jul 26 14:46:15 2022 +0100 Redesign xtra's spawn API (#156) * Redesign xtra's spawn API This removes `Actor::create`, `ActorManager` and the various runtime extension traits in favor of top-level free functions for spawning an actor instance into a specific runtime. This is deemed to be more ergonomic because: - Users do not need to import an extension trait for their runtime - Users do not need to import the `Actor` trait to run it which was otherwise required to call `create`. - The implementation has less indirection, thus making it easier for users to understand and perhaps adapt / write their own `spawn` fn depending on their needs. The implementation is not strictly functionally equivalent to what we had before. In particular, we no longer support spawning in a runtime handle of the tokio and smol runtimes. We accept this regression because we assume that it is a niche usecase and the now easier implementation should showcase users, how they can easily write themselves a helper function that spawns an actor using a runtime handle in a single line of code. In other words, the `spawn` API of xtra is purposely design to make 80% of usecases work. For everything else, users should write their own `spawn` function. Closes #136. commit 285b3e9 Author: Restioson <restiosondev@gmail.com> Date: Fri Jul 22 16:03:28 2022 +0200 Use or_current when creating spans (#154) * Use or_current when creating spans This makes sure that if the xtra_actor_request is disabled, the other spans and child-spans of xtra_message_handler will be children of the would-be parent of xtra_actor_request, rather than being parentless, top-level spans. * Add test for or_current commit 3d063ff Author: Thomas Eizinger <thomas@eizinger.io> Date: Fri Jul 22 11:50:53 2022 +0100 Move capacity from `Chan` to `ChanInner` (#150) This allows us to avoid some back and forth passing of data which makes a few functions have less arguments and overall better ergonomics. commit 4b5f8af Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 21 23:27:05 2022 +0100 Encapsulate more functionality in `WaitingReceiver` (#149) * Make `WakeReason` an implementation detail of `WaitingReceiver` We can achieve this by having more specific functions on `WaitingReceiver` itself. * Introduce `FulfillHandle` for `WaitingReceiver` Previously, the references to `WaitingReceiver` were stored "naked" within the channel and the `Future` implementation. This made it hard to understand that there are only ever two references. This patch introduces those two references as proper types and adds documentation on how the `WaitingReceiver` works. * Store cancellation state in boolean flag This avoids an "unreachable" branch when polling the receiver. * Make `WakeReason` an implementation detail of `WaitingReceiver` We can achieve this by making a custom `poll` function on `WaitingReceiver` and passing `Receiver` as a reference in. * Make `WakeReason` private This is possible, now that we made it an implementation detail of `WaitingReceiver`. * Move `WaitingReceiver` to its own module This component houses a good chunk of functionality now and is better understood in isolation. Additionally, this allows us to better enforce visibility of types. * Introduce dedicated `Waiting` sub-state This allows for a more focused `Drop` implementation. * Use `catty` to implement `WaitingReceiver` (#151) Now that the waker management is encapsulated in catty, `WakeReason` is no longer an accurate name. `CtrlMsg` seems better. Additionally, instead of "fulfilling" the waiting receiver, the language of "notifying" feels more natural. * Remove dependency on catty patch (#153) * Remove dependency on catty patch Co-authored-by: Restioson <restiosondev@gmail.com> * Update src/inbox.rs Co-authored-by: Restioson <restiosondev@gmail.com> commit eab4691 Author: Thomas Eizinger <thomas@eizinger.io> Date: Thu Jul 21 22:24:42 2022 +0100 Update `with-tracing-0_1` feature docs to `instrumentation` feature (#152) * Remove mention of outdated feature * Mention `instrumentation` feature commit eafe175 Author: Thomas Eizinger <thomas@eizinger.io> Date: Tue Jul 19 13:09:14 2022 +0100 Unify message sending into one `SendFuture` (#147) * Have `SendFuture` handle every case of sending messages This one future now handles: - Sending a single message with the actor type being named - Sending a single message with the actor type being erased - Sending a broadcast message with the actor type being named * Add SendFuture::broadcast_erased Using this function takes a few more changes but it is added here because it will definitely be useful later. * Employ "double result" pattern for `try_send` Using a double result is useful in cases where the errors returned by a function fall into two categories: recoverable and non-recoverable. A disconnected channel is not recoverable and we can thus directly forward it with `?`. The mailbox being full is something we need to deal with in `SendFuture` which is why it is within another layer of `Result`. commit ff782ad Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 18:52:27 2022 +0100 Don't pass message name into envelope (#148) * Don't pass message name into envelope An envelope knows which message it is carrying, no need to pass it in. * Remove `MessageKind` Without the additional field for the message's name, this layer does not serve any purpose. commit 910f3fb Author: Restioson <restiosondev@gmail.com> Date: Mon Jul 18 17:35:52 2022 +0200 Strip span fields from waiting and handler spans (#145) Currently, these are always children of the request span, so adding them as fields in them too is redundant. It would be a simplification to move this just to xtra_message_handler, but this is unfortunately not possible in the case of a disconnected actor which will never handle the message - this would miss all actor and message type information. commit a0c1ad6 Author: Restioson <restiosondev@gmail.com> Date: Mon Jul 18 14:05:29 2022 +0200 Improve span variables in tracing spans (#143) * Rename message -> message_type Weird behaviour is exhibited by some subscribers with `message` as a field name, probably since it is reserved, so `message_type` is used instead. "actor" was also renamed "actor_type" for consistency. Also, the display implementation of type name strings are used to avoid unnecessary quotes in the output. commit a2bedd5 Author: Restioson <restiosondev@gmail.com> Date: Mon Jul 18 13:05:57 2022 +0200 Create spans late (#120) Create the actor request span after first poll of `send` in order to ensure `send(...).instrument(...)` works as expected. commit 7b0b6ea Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 09:53:35 2022 +0100 Always store message priority in envelope (#142) * Always store message priority in envelope Previously, we only stored the priority of broadcast messages in the envelope. For regular messages, the priority was stored outside in a wrapper struct. This disparity is hard to understand as there is no apparent reason why the priority could not be stored in the message envelope. With this patch, we move the priority into the message envelope and also expose a `set_priority` function for each envelope type which allows us to consolidate the way we set priority from the `SendFuture`. To allow this, message envelopes need to be employ interior mutability (they are either box'ed or arc'ed). We use a spin lock which should basically be free. A `SendFuture` cannot be cloned and thus will never be accessed from two different threads, meaning the lock will never be congested. commit fd3c282 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 09:41:54 2022 +0100 Remove `ReceiveFuture::cancel` in favor of cancellation-safety docs (#138) Remove `ReceiveFuture::cancel` in favor of cancellation-safety docs, which fixes #134. Tests were added to check behaviour of resending messages on drop. commit 07e4664 Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 09:10:48 2022 +0100 Introduce optional `sink` feature (#140) * Introduce optional `sink` feature Not every user may need the `sink` feature and we can minimise our dependency tree in those cases. * Extend README docs * Fix docs commit bc7808c Author: Thomas Eizinger <thomas@eizinger.io> Date: Mon Jul 18 07:07:45 2022 +0100 Move channel logic into `Chan` (#122) Move the channel logic (e.g try_send and try_recv) into Chan itself. The goal was is follows: - Have Chan house the core channel implementation with descriptive function names for key operations - Have Sender and Receiver be thin layers on top that combine Chan with reference counting and provide a Future-based APIs for sending and receiving commit e54b413 Author: Restioson <restiosondev@gmail.com> Date: Sun Jul 17 20:52:20 2022 +0200 Annotate TickFuture with must_use (#139) This is since it is a future
Fixes #127.