Skip to content
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

Tidy-up README and CHANGELOG #212

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 34 additions & 23 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,43 @@

## 0.6.0

- Sealed `RefCounter` trait
- `Message` no longer exists - `Return` is now specified on the `Handler` trait itself.
- `stopping` has been removed in favour of `stop_self` and `stop_all`. If logic to determine if the actor should stop
must be executed, it should be done rather at the point of calling `stop_{self,all}`.
- Previously, `stop_all` would immediately disconnect the address. However, `stop_self` done on every actor would actually
not do this in one case - if there were a free-floating (not executing an actor event loop) Context. This change brings
`stop_all` in line with `stop_self`.
- `MessageChannel` is now a `struct` that can be constructed from an `Address` via `MessageChannel::new` or using
`From`/`Into`.
### Added

- `xtra::Actor` custom-derive when the `macros` features is enabled.

### Changed

- `MessageChannel` is now a `struct` that can be constructed from an `Address` via `MessageChannel::new` or using `From`/`Into`.
- Move event-loop related functions from `Context` to xtra's top-level scope.
`Context` is now only used within an actor's `Handler`.
The default event-loop now lives at `xtra::run`, next to `xtra::select`, `xtra::join`, `xtra::yield`.
- Redesign "spawn" interface:
Remove `Actor::create`, `ActorManager` and extension traits for spawning.
Introduce `xtra::spawn_tokio`, `xtra::spawn_smol`, `xtra::spawn_async_std` and `xtra::spawn_wasm_bindgen`.
- Previously, `stop_all` would immediately disconnect the address.
However, `stop_self` done on every actor would actually not do this in one case - if there were a free-floating (not executing an actor event loop) Context.
This change brings `stop_all` in line with `stop_self`.
- `stop_all` now does not drain all messages when called, and acts just like `stop_self` on all active actors.
- Rename features from `with-crate-version` to just `crate`. For example, `with-tokio-1` has been renamed to `tokio`.
- Sealed `RefCounter` trait.

### Removed

- `AddressSink` was removed in favor of using `impl Trait` for the `Address::into_sink` method.
- `Context::attach_stream` was removed in favor of composing `Stream::forward` and `Address::into_sink`.
- `KeepRunning` was removed as `Context::attach_stream` was its last usage.
- `InstrumentedExt` was removed. All messages are now instrumented automatically when `instrumentation` is enabled.
- `stop_all` now does not drain all messages when called, and acts just like `stop_self` on all active actors.
- `Context::attach` is removed in favor of implementing `Clone` for `Context`. If you want to run multiple actors on a
`Context`, simply clone it before calling `run`.
- Remove `Context::notify_after` without a direct replacement. To delay the sending of a message, users are encouraged
to use the `sleep` function of their executor of choice and combine it with `Address::send` into a new future. To
cancel the sleeping early in case the actor stops, use `xtra::scoped`.
- Remove `Context::notify_interval` without a direct replacement. Users are encouraged to write their own loop within
which they call `Address:send`.
- Rename features from `with-crate-version` to just `crate`. For example, `with-tokio-1` has been renamed to `tokio`.
- Redesign "spawn" interface: Remove `Actor::create`, `ActorManager` and extension traits for spawning in favor of
`xtra::spawn_tokio`, `xtra::spawn_smol`, `xtra::spawn_async_std` and `xtra::spawn_wasm_bindgen`.
- Move event-loop related functions from `Context` to xtra's top-level scope. `Context` is now only used within an
actor's `Handler`. The default event-loop now lives at `xtra::run`, next to `xtra::select`, `xtra::join`, `xtra::yield`.
- `InstrumentedExt` was removed.
All messages are now instrumented automatically when `instrumentation` is enabled.
- `Message` no longer exists: `Return` is now specified on the `Handler` trait itself.
- `stopping` has been removed in favour of `stop_self` and `stop_all`.
If logic to determine if the actor should stop must be executed, it should be done rather at the point of calling `stop_{self,all}`.
- `Context::attach` is removed in favor of implementing `Clone` for `Context`.
If you want to run multiple actors on a `Context`, simply clone it before calling `run`.
- Remove `Context::notify_after` without a direct replacement.
To delay the sending of a message, users are encouraged to use the `sleep` function of their executor of choice and combine it with `Address::send` into a new future.
To cancel the sleeping early in case the actor stops, use `xtra::scoped`.
- Remove `Context::notify_interval` without a direct replacement.
Users are encouraged to write their own loop within which they call `Address:send`.

## 0.5.0

Expand Down
33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
![Matrix](https://img.shields.io/matrix/xtra-community:matrix.org)

# xtra
A tiny, fast, and safe actor framework. It is modelled around Actix (copyright and license [here](https://github.com/Restioson/xtra/blob/master/LICENSE-ACTIX)).

For better ergonomics with xtra, try the [spaad](https://crates.io/crates/spaad) crate.
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
A tiny, fast, and safe actor framework. It is modelled around Actix (copyright and license [here](https://github.com/Restioson/xtra/blob/master/LICENSE-ACTIX)).

## Features
- Safe: there is no unsafe code in xtra.
- Tiny: xtra is around 2kloc.
- Lightweight: xtra has few dependencies, most of which are lightweight (except `futures`).
- Asynchronous `Handler` interface which allows `async`/`await` syntax even when borrowing `self`.

- **Safe:** there is no unsafe code in xtra.
- **Tiny:** xtra is only around 2000 LoC.
- **Lightweight:** xtra has few dependencies, most of which are lightweight (except `futures`).
- Asynchronous `Handler` interface which allows `async`/`await` syntax with `&mut self`.
- Does not depend on its own runtime and can be run with any futures executor. Convenience `spawn` functions are provided
for [Tokio](https://tokio.rs/), [async-std](https://async.rs/), [smol](https://github.com/stjepang/smol), and
[wasm-bindgen-futures](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/).
- Quite fast. Running on Tokio, <170ns time from sending a message to it being processed for sending without waiting for a
result on my development machine with an AMD Ryzen 3 3200G.
- However, it is also relatively new and less mature than other options.

## Example
```rust
Expand Down Expand Up @@ -52,31 +51,29 @@ async fn main() {

```

For a longer example, check out [Vertex](https://github.com/Restioson/vertex/tree/development), a chat application
written with xtra and spaad on the server.

Too verbose? Check out the [spaad](https://crates.io/crates/spaad) sister-crate!
For a longer example, check out [Vertex](https://github.com/Restioson/vertex/tree/development), a chat application written with xtra and spaad on the server.

## Okay, sounds great! How do I use it?
Check out the [docs](https://docs.rs/xtra) and the [examples](https://github.com/Restioson/xtra/blob/master/examples)
to get started! Enabling the `tokio`, `async_std`, `smol`, or `wasm_bindgen` features
is recommended in order to enable some convenience methods (such as `xtra::spawn_tokio`). Which you enable will depend on
which executor you want to use (check out their docs to learn more about each). If you have any questions, feel free to
[open an issue](https://github.com/Restioson/xtra/issues/new) or message me on the [Rust discord](https://bit.ly/rust-community).

Check out the [docs](https://docs.rs/xtra) and the [examples](https://github.com/Restioson/xtra/blob/master/examples) to get started!
Enabling the `tokio`, `async_std`, `smol`, or `wasm_bindgen` features is recommended in order to enable some convenience methods (such as `xtra::spawn_tokio`).
Which you enable will depend on which executor you want to use (check out their docs to learn more about each).
If you have any questions, feel free to [open an issue](https://github.com/Restioson/xtra/issues/new) or message me on the [Rust discord](https://bit.ly/rust-community).
Comment on lines +58 to +61
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to one sentence per line to make working with github's suggestion easier.


Keep in mind that `xtra` has a MSRV of 1.60.0.

## Cargo features

- `async_std`: enables integration with [async-std](https://async.rs/).
- `smol`: enables integration with [smol](https://github.com/smol-rs/smol). Note that this requires smol 1.1 as
1.1 had a minor breaking change from 1.0 which leads to xtra no longer compiling on 1.0 and 1.1 simultaneously.
- `smol`: enables integration with [smol](https://github.com/smol-rs/smol).
Note that this requires smol 1.1 as 1.1 had a minor breaking change from 1.0 which leads to xtra no longer compiling on 1.0 and 1.1 simultaneously.
- `tokio`: enables integration with [tokio](https://tokio.rs).
- `wasm_bindgen`: enables integration with [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen), and particularly its futures crate.
- `instrumentation`: Adds a dependency on `tracing` and creates spans for message sending and handling on actors.
- `sink`: Adds `Address::into_sink` and `MessageChannel::into_sink`.
- `macros`: Enables the `Actor` custom derive macro.

## Latest Breaking Changes

To see the breaking changes for each version, see [here](https://github.com/Restioson/xtra/blob/master/BREAKING-CHANGES.md).
The latest version is 0.6.0.