diff --git a/.gitignore b/.gitignore index 024a3d3..ed50a8c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ guide/build/ # Folder generated by mdbook when following the README.md instructions. /actix/book + +# intellij files +**/.idea diff --git a/Cargo.toml b/Cargo.toml index 2c6c6b6..139efa3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,9 @@ categories = ["network-programming", "asynchronous", "web-programming::websocket"] license = "MIT OR Apache-2.0" exclude = [".gitignore", "/.github", ".cargo/config"] -edition = "2018" +edition = "2021" [dependencies] -actix = "0.10.0" -actix-rt = "1.1" - +actix = "0.13" +actix-rt = "2.7" doc-comment = "0.3" diff --git a/README.md b/README.md index e89347f..0b7d209 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ This repository is an [`mdBook`](https://github.com/rust-lang/mdBook) project. To use it for this project: -- Install `mdBook` if you haven't already: `cargo install mdbook` -- In the `actix` directory: `mdbook watch -o` +- Install `mdBook`: `cargo install mdbook` +- Install `linkcheck`: `cargo install mdbook-linkcheck` +- Run from repo root: `mdbook watch -o actix` - This automatically opens your browser and watches the md files for changing - - You'll still have to refresh the page, as there is no hot-reloading for - `mdbook` + - You'll still have to refresh the page, as there is no hot-reloading for `mdbook` diff --git a/actix/src/sec-0-quick-start.md b/actix/src/sec-0-quick-start.md index 096d0b5..cdc2c37 100644 --- a/actix/src/sec-0-quick-start.md +++ b/actix/src/sec-0-quick-start.md @@ -17,7 +17,7 @@ If you already have rustup installed, run this command to ensure you have the la rustup update ``` -The actix framework requires Rust version 1.40.0 and up. +The actix framework requires Rust version 1.54.0 and up. ## Running Examples @@ -31,4 +31,4 @@ cd actix cargo run --example ping ``` -Check [examples/](https://github.com/actix/actix/tree/master/actix/examples) directory for more examples. +Check [examples/](https://github.com/actix/actix/tree/HEAD/actix/examples) directory for more examples, or see many more [community examples](https://github.com/actix/examples). diff --git a/actix/src/sec-1-getting-started.md b/actix/src/sec-1-getting-started.md index b7d3a71..696d76a 100644 --- a/actix/src/sec-1-getting-started.md +++ b/actix/src/sec-1-getting-started.md @@ -20,8 +20,8 @@ contains the following: ```toml [dependencies] -actix = "0.11.0" -actix-rt = "2.2" # <-- Runtime for actix +actix = "0.13" +actix-rt = "2.7" # <-- Runtime for actix ``` Let's create an actor that will accept a `Ping` message and respond with the number of pings processed. @@ -29,7 +29,6 @@ Let's create an actor that will accept a `Ping` message and respond with the num An actor is a type that implements the `Actor` trait: ```rust -# extern crate actix; use actix::prelude::*; struct MyActor { @@ -50,7 +49,6 @@ Now we need to define the `Message` that the actor needs to accept. The message that implements the `Message` trait. ```rust -# extern crate actix; use actix::prelude::*; #[derive(Message)] @@ -68,7 +66,6 @@ And finally, we need to declare that our actor `MyActor` can accept `Ping` and h To do this, the actor needs to implement the `Handler` trait. ```rust -# extern crate actix; # use actix::prelude::*; # # struct MyActor { @@ -114,8 +111,6 @@ Here we use the actix-rt as way to start our System and drive our main Future so we can easily `.await` for the messages sent to the Actor. ```rust -# extern crate actix; -# extern crate actix_rt; # use actix::prelude::*; # struct MyActor { # count: usize, diff --git a/actix/src/sec-2-actor.md b/actix/src/sec-2-actor.md index bc52b30..6f52d51 100644 --- a/actix/src/sec-2-actor.md +++ b/actix/src/sec-2-actor.md @@ -75,7 +75,6 @@ Let's define a simple `Ping` message - an actor which will accept this message n `Result`. ```rust -# extern crate actix; use actix::prelude::*; struct Ping; @@ -99,8 +98,6 @@ creating actors; for details check the docs. ## Complete example ```rust -# extern crate actix; -# extern crate actix_rt; use actix::prelude::*; /// Define message @@ -170,8 +167,6 @@ Here's an example where we're responding to a `Ping` message with a `GotPing`, and responding with `GotPong` for a `Pong` message. ```rust -# extern crate actix; -# extern crate actix_rt; use actix::dev::{MessageResponse,OneshotSender}; use actix::prelude::*; @@ -192,7 +187,7 @@ where A: Actor, M: Message, { - fn handle(self, ctx: &mut A::Context, tx: Option>) { + fn handle(self, _ctx: &mut A::Context, tx: Option>) { if let Some(tx) = tx { tx.send(self); } diff --git a/actix/src/sec-3-address.md b/actix/src/sec-3-address.md index 6b31494..035b3f6 100644 --- a/actix/src/sec-3-address.md +++ b/actix/src/sec-3-address.md @@ -10,8 +10,9 @@ Here is an example of `Actor::start()` method usage. In this example `MyActor` a is asynchronous and is started in the same thread as the caller - threads are covered in the [SyncArbiter] chapter. -```rust -# extern crate actix; +```rust, should_panic +// FIXME: THIS EXAMPLE IS BROKEN, AND NEEDS TO BE FIXED + # use actix::prelude::*; # struct MyActor; @@ -20,7 +21,7 @@ impl Actor for MyActor { } # fn main() { -# System::new("test"); +# System::new(); let addr = MyActor.start(); # } ``` @@ -29,7 +30,6 @@ An async actor can get its address from the `Context` struct. The context needs implement the `AsyncContext` trait. `AsyncContext::address()` provides the actor's address. ```rust -# extern crate actix; # use actix::prelude::*; # struct MyActor; @@ -88,8 +88,8 @@ For example recipient can be used for a subscription system. In the following ex `OrderEvents` actor sends a `OrderShipped` message to all subscribers. A subscriber can be any actor that implements the `Handler` trait. -```rust -# extern crate actix; +```rust, should_panic +// FIXME: THIS EXAMPLE IS BROKEN, AND NEEDS TO BE FIXED use actix::prelude::*; #[derive(Message)] @@ -177,7 +177,7 @@ impl Handler for SmsSubscriber { } fn main() { - let system = System::new("events"); + let system = System::new(); let email_subscriber = Subscribe(EmailSubscriber{}.start().recipient()); let sms_subscriber = Subscribe(SmsSubscriber{}.start().recipient()); let order_event = OrderEvents::new().start(); diff --git a/actix/src/sec-4-context.md b/actix/src/sec-4-context.md index 328c584..bcf339e 100644 --- a/actix/src/sec-4-context.md +++ b/actix/src/sec-4-context.md @@ -11,8 +11,8 @@ calls specific message handlers. Mailboxes in general are bounded. The capacity specific to the context implementation. For the `Context` type the capacity is set to 16 messages by default and can be increased with [`Context::set_mailbox_capacity()`]. -```rust -# extern crate actix; +```rust, should_panic +// FIXME: THIS EXAMPLE IS BROKEN, AND NEEDS TO BE FIXED # use actix::prelude::*; # struct MyActor; @@ -26,7 +26,7 @@ impl Actor for MyActor { } # fn main() { -# System::new("test"); +# System::new(); let addr = MyActor.start(); # } ``` @@ -46,8 +46,8 @@ to a message. If you want an actor to send a message to itself, have a look at To get your address from the context you call [`Context::address()`]. An example is: -```rust -# extern crate actix; +```rust, should_panic +// FIXME: THIS EXAMPLE IS BROKEN, AND NEEDS TO BE FIXED # use actix::prelude::*; # struct MyActor; @@ -71,7 +71,7 @@ impl Handler for MyActor { } # fn main() { -# System::new("scratch"); +# System::new(); # let addr = MyActor.start(); let who_addr = addr.do_send(WhoAmI{}); # } @@ -88,8 +88,6 @@ of program shutdown. To do this you call [`Context::stop()`]. This is an adjusted Ping example that stops after 4 pings are received. ```rust -# extern crate actix; -# extern crate actix_rt; # use actix::prelude::*; # struct MyActor { # count: usize, diff --git a/actix/src/sec-5-arbiter.md b/actix/src/sec-5-arbiter.md index 7fd7e55..d2f271f 100644 --- a/actix/src/sec-5-arbiter.md +++ b/actix/src/sec-5-arbiter.md @@ -46,8 +46,8 @@ wrapper to resolving async events in order. Consider we have two actors, A and B, and we want to run an event on B only once a result from A is completed. We can use `Arbiter::spawn` to assist with this task. -```rust -# extern crate actix; +```rust, should_panic +// FIXME: THIS EXAMPLE IS BROKEN, AND NEEDS TO BE FIXED use actix::prelude::*; struct SumActor {} @@ -87,7 +87,7 @@ impl Handler for DisplayActor { } fn main() { - let system = System::new("single-arbiter-example"); + let system = System::new(); // Define an execution flow using futures let execution = async { @@ -115,7 +115,7 @@ fn main() { }; // Spawn the future onto the current Arbiter/event loop - Arbiter::spawn(execution); + actix_rt::spawn(execution); // We only want to do one computation in this example, so we // shut down the `System` which will stop any Arbiters within diff --git a/actix/src/sec-6-sync-arbiter.md b/actix/src/sec-6-sync-arbiter.md index 7145579..0ec826b 100644 --- a/actix/src/sec-6-sync-arbiter.md +++ b/actix/src/sec-6-sync-arbiter.md @@ -18,7 +18,6 @@ When implementing your Actor to be run on a SyncArbiter, it requires that your A Context is changed from `Context` to `SyncContext`. ```rust -# extern crate actix; use actix::prelude::*; struct MySyncActor; @@ -28,7 +27,7 @@ impl Actor for MySyncActor { } # # fn main() { -# System::new("test"); +# System::new(); # } ``` @@ -39,7 +38,6 @@ our `SyncArbiter`. We can only control the number of threads at SyncArbiter crea time - we can't add/remove threads later. ```rust -# extern crate actix; use actix::prelude::*; struct MySyncActor; @@ -49,7 +47,7 @@ impl Actor for MySyncActor { } # fn main() { -# System::new("test"); +# System::new(); let addr = SyncArbiter::start(2, || MySyncActor); # } ```