From 669975df75ac9a6da9dccf69ef0e650effa343ae Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 18 Dec 2017 20:00:57 -0800 Subject: [PATCH] fix typos --- guide/src/qs_14.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/guide/src/qs_14.md b/guide/src/qs_14.md index 38ea411cf..e92375c43 100644 --- a/guide/src/qs_14.md +++ b/guide/src/qs_14.md @@ -3,13 +3,13 @@ ## Diesel At the moment of 1.0 release Diesel does not support asynchronous operations. -But it possible to use `actix` synchronous actor as an db interface api. -Multipl sync actors could be started, in this case all of this actor -process messages from same queu (sync actors actually work mpmc mode). +But it possible to use `actix` synchronous actor system as a db interface api. +Multiple sync actors could be run in parallel, in this case all of this actors +process messages from the same queue (sync actors actually work in mpmc mode). Let's create simple db api that can insert new user row into sqlite table. We need to define sync actor and connection that this actor will use. Same approach -could used for other databases: +could used for other databases. ```rust,ignore use actix::prelude::*;* @@ -21,7 +21,7 @@ impl Actor for DbExecutor { } ``` -This is definition of our actor. Now we need to define *create user* message. +This is definition of our actor. Now we need to define *create user* message and response. ```rust,ignore struct CreateUser { @@ -35,10 +35,11 @@ impl ResponseType for CreateUser { ``` We can send `CreateUser` message to `DbExecutor` actor, and as result we can get -`User` model. Now we need to define actual handler for this message. +`User` model. Now we need to define actual handler implementation for this message. ```rust,ignore impl Handler for DbExecutor { + fn handle(&mut self, msg: CreateUser, _: &mut Self::Context) -> Response { use self::schema::users::dsl::*; @@ -67,10 +68,9 @@ impl Handler for DbExecutor { ``` That is it. Now we can use *DbExecutor* actor from any http handler or middleware. -All we need is to start *DbExecutor* actors and store address in state where http endpoint +All we need is to start *DbExecutor* actors and store address in state where http handler can access it. - ```rust,ignore /// This is state where we sill store *DbExecutor* address. struct State { @@ -97,7 +97,7 @@ fn main() { } ``` -And finally we can use this handler function. We get message response +And finally we can use this state in handler function. We get message response asynchronously, so handler needs to return future object, also `Route::a()` needs to be used for async handler registration.