Update README.md
This commit is contained in:
32
README.md
32
README.md
@@ -20,11 +20,13 @@
|
||||
* Code structure
|
||||
* Running the application
|
||||
|
||||
### Code Structure
|
||||
## Code Structure
|
||||
|
||||
### Running the application
|
||||
TBC
|
||||
|
||||
#### Requirements
|
||||
## Running the application
|
||||
|
||||
### Requirements
|
||||
|
||||
* Just install [docker](http://docs.docker.com/get-docker/).
|
||||
* If you want to run PHP locally and leave docker for just external services (mysql, redis, elastic and rabbitmq):
|
||||
@@ -32,7 +34,7 @@
|
||||
* Needed PHP extensions: pdo_mysql, mysqli, amqp.
|
||||
* Make sure to install [Symfony CLI](http://symfony.com/download).
|
||||
|
||||
#### 🐳 Full Docker
|
||||
### 🐳 Full Docker
|
||||
|
||||
This code can run fully on docker. In order to do so just run
|
||||
|
||||
@@ -48,7 +50,7 @@ And to stop all services just run
|
||||
|
||||
Cheeper starts totally as a blank application. There is no Author, Cheeps, Follows, etc. Let's see what happens with the existing Projections when
|
||||
|
||||
##### Follower Counters Query
|
||||
#### Follower Counters Query
|
||||
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/followers-counter
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/followers-counter
|
||||
@@ -61,7 +63,7 @@ Expected output
|
||||
"data": "Author \"a64a52cc-3ee9-4a15-918b-099e18b43119\" does not exist"
|
||||
}
|
||||
|
||||
##### Author Timeline
|
||||
#### Author Timeline
|
||||
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/timeline
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/timeline
|
||||
@@ -75,7 +77,7 @@ Expected output
|
||||
}
|
||||
...
|
||||
|
||||
##### Adding Authors
|
||||
#### Adding Authors
|
||||
|
||||
Cheeper is configured so signing up new Authors is a synchronous operations. This mean that once the HTTP request made to the Cheeper API is finished, the Author will be in the database without having to perform any other action. As soon the API receives the request, the SignUpCommand is created and delegated to the Command Bus. The Command Bus will check the routing configurations and it will pass the Command to the SignUpCommandHandler that will perform all the actions required to sign up a new Author.
|
||||
|
||||
@@ -93,7 +95,7 @@ Expected output
|
||||
|
||||
The response to the HTTP request and the Authors in the database are not the only outcome generated. In RabbitMQ, there are store multiple events of type `NewAuthorSigned`. Those Domain Events are waiting to be handled. In order to do so, they will have to be consumed. Until not getting consumed, the Follower Counters Query will still return a 404 HTTP Status Code.
|
||||
|
||||
##### Consuming Events
|
||||
#### Consuming Events
|
||||
|
||||
php bin/console messenger:consume events_async
|
||||
|
||||
@@ -113,7 +115,7 @@ There is one `NewAuthorSigned` event to handle for each new Author signed in. Th
|
||||
|
||||
Now, that all the Domain Events are processed, and their corresponding Projections are calculated, the queries to check how many followers - an Author has - are not empty anymore.
|
||||
|
||||
##### Follower Counters Query
|
||||
#### Follower Counters Query
|
||||
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/followers-counter
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/followers-counter
|
||||
@@ -133,7 +135,7 @@ Expected output
|
||||
}
|
||||
...
|
||||
|
||||
##### Author Timeline
|
||||
#### Author Timeline
|
||||
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/timeline
|
||||
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/timeline
|
||||
@@ -145,18 +147,18 @@ Expected output
|
||||
"cheeps": []
|
||||
}
|
||||
|
||||
##### Following other Authors
|
||||
#### Following other Authors
|
||||
|
||||
Following an Author is a Command that is defined as asynchronous. This means that once the request to the Cheeper API is done, the Command will wait to be processed by a worker. The initial HTTP request to the API returns really fast, but the changes in the database will not be done until the Command is processed.
|
||||
|
||||
http --json --body POST http://127.0.0.1:8000/chapter7/follow follow_id="8cc71bf2-f827-4c92-95a5-43bb1bc622ad" from_author_id="1fd7d739-2ad7-41a8-8c18-565603e3733f" to_author_id="a64a52cc-3ee9-4a15-918b-099e18b43119"
|
||||
http --json --body POST http://127.0.0.1:8000/chapter7/follow follow_id="f3088920-841e-4577-a3c2-efdc80f0dea5" from_author_id="1da1366f-b066-4514-9b29-7346df41e371" to_author_id="a64a52cc-3ee9-4a15-918b-099e18b43119"
|
||||
|
||||
# consume
|
||||
#### Consuming Events
|
||||
|
||||
php bin/console messenger:consume events_async
|
||||
|
||||
##### Follower Counters Query
|
||||
#### Follower Counters Query
|
||||
|
||||
http --json http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/followers-counter
|
||||
http --json http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/followers-counter
|
||||
@@ -175,13 +177,13 @@ Expected output
|
||||
}
|
||||
}
|
||||
|
||||
##### Posting Cheeps
|
||||
#### Posting Cheeps
|
||||
|
||||
http --json --body POST http://127.0.0.1:8000/chapter7/cheep cheep_id="28bc90bd-2dfb-4b71-962f-81f02b0b3149" author_id="a64a52cc-3ee9-4a15-918b-099e18b43119" message="Hello world, this is Bob"
|
||||
http --json --body POST http://127.0.0.1:8000/chapter7/cheep cheep_id="04efc3af-59a3-4695-803f-d37166c3af56" author_id="1fd7d739-2ad7-41a8-8c18-565603e3733f" message="Hello world, this is Alice"
|
||||
http --json --body POST http://127.0.0.1:8000/chapter7/cheep cheep_id="8a5539e6-3be2-4fa7-906e-179efcfca46b" author_id="1da1366f-b066-4514-9b29-7346df41e371" message="Hello world, this is Charlie"
|
||||
|
||||
##### Author Timeline
|
||||
#### Author Timeline
|
||||
|
||||
http --json http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/timeline
|
||||
http --json http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/timeline
|
||||
|
||||
Reference in New Issue
Block a user