mirror of
https://github.com/actix/actix-website
synced 2024-11-23 16:31:08 +01:00
docs: remove actix_rt references
This commit is contained in:
parent
ad4aeac34f
commit
d0f91408ed
@ -3,6 +3,9 @@ title: Getting Started
|
|||||||
slug: /actix/getting-started
|
slug: /actix/getting-started
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import RenderCodeBlock from '@theme/CodeBlock';
|
||||||
|
import vars from "@site/vars";
|
||||||
|
|
||||||
# Getting Started
|
# Getting Started
|
||||||
|
|
||||||
Let’s create and run our first actix application. We’ll create a new Cargo project that depends on actix and then run the application.
|
Let’s create and run our first actix application. We’ll create a new Cargo project that depends on actix and then run the application.
|
||||||
@ -20,11 +23,11 @@ cd actor-ping
|
|||||||
|
|
||||||
Now, add actix as a dependency of your project by ensuring your Cargo.toml contains the following:
|
Now, add actix as a dependency of your project by ensuring your Cargo.toml contains the following:
|
||||||
|
|
||||||
```toml
|
<RenderCodeBlock className="language-toml">
|
||||||
[dependencies]
|
{`[dependencies]
|
||||||
actix = "0.11.0"
|
actix = "${vars.actorsMajorVersion}"
|
||||||
actix-rt = "2.2" # <-- Runtime for actix
|
`}
|
||||||
```
|
</RenderCodeBlock>
|
||||||
|
|
||||||
Let's create an actor that will accept a `Ping` message and respond with the number of pings processed.
|
Let's create an actor that will accept a `Ping` message and respond with the number of pings processed.
|
||||||
|
|
||||||
@ -76,10 +79,10 @@ All communication with actors goes through an address. You can `do_send` a messa
|
|||||||
|
|
||||||
In the following example we are going to create a `MyActor` actor and send one message.
|
In the following example we are going to create a `MyActor` actor and send one message.
|
||||||
|
|
||||||
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.
|
Here we use the `#[actix::main]` as way to start our System and drive our main Future so we can easily `.await` for the messages sent to the Actor.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[actix_rt::main]
|
#[actix::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// start new actor
|
// start new actor
|
||||||
let addr = MyActor { count: 10 }.start();
|
let addr = MyActor { count: 10 }.start();
|
||||||
@ -95,6 +98,6 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`#[actix_rt::main]` starts the system and block until future resolves.
|
`#[actix::main]` starts the system and block until future resolves.
|
||||||
|
|
||||||
The Ping example is available in the [examples directory](https://github.com/actix/actix/tree/master/actix/examples/).
|
The Ping example is available in the [examples directory](https://github.com/actix/actix/tree/master/actix/examples/).
|
||||||
|
@ -107,7 +107,7 @@ impl Handler<Ping> for MyActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Start MyActor in current thread
|
// Start MyActor in current thread
|
||||||
let addr = MyActor.start();
|
let addr = MyActor.start();
|
||||||
@ -191,7 +191,7 @@ impl Handler<Messages> for MyActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Start MyActor in current thread
|
// Start MyActor in current thread
|
||||||
let addr = MyActor.start();
|
let addr = MyActor.start();
|
||||||
|
@ -83,7 +83,7 @@ impl Handler<Ping> for MyActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// start new actor
|
// start new actor
|
||||||
let addr = MyActor { count: 10 }.start();
|
let addr = MyActor { count: 10 }.start();
|
||||||
|
Loading…
Reference in New Issue
Block a user