Skip to content

Latest commit

 

History

History
176 lines (105 loc) · 2.3 KB

20_Worker_Services.md

File metadata and controls

176 lines (105 loc) · 2.3 KB

[Stephen Grider] Microservices with Node JS and React [ENG, 2020]

20. Worker Services


01. The Expiration Service


Application


02. Expiration Options


Application


03. Initial Setup

$ cd expiration

copy some codes from tickets

$ npm install --save bull @types/bull

04. A Touch of Kubernetes Setup


05. File Sync Setup

$ cd skaffold
$ skaffold dev

06. Listener Creation


07. What's Bull All About


Application


08. Creating a Queue


Application


09. Queueing a Job on Event Arrival


10. Testing Job Processing

CREATE TICKET

// CREATE ORDER
$ curl \
--insecure \
--cookie /tmp/cookies.txt \
--data '{"ticketId":"5ec43c86298c01001811bbb7"}' \
--header "Content-Type: application/json" \
--request POST https://ticketing.dev/api/orders \
| python -m json.tool

response:

{
    "expiresAt": "2020-05-19T20:23:05.480Z",
    "id": "5ec43ca50880b600192cf43d",
    "status": "created",
    "ticket": {
        "id": "5ec43c86298c01001811bbb7",
        "price": 10,
        "title": "concert",
        "version": 0
    },
    "userId": "5ec43c7cb0fd040023683c8b",
    "version": 0
}

Application


10. Testing Job Processing


11. Delaying Job Processing


12. Defining the Expiration Complete Event

$ cd expiration
$ npm update @grider-ms-tickets/common

$ cd orders
$ npm update @grider-ms-tickets/common

13. Publishing an Event on Job Processing


14. Handling an Expiration Event


15. Emitting the Order Cancelled Event


16. Testing the Expiration Complete Listener


17. A Touch More Testing

$ cd orders
$ npm run test

18. Listening for Expiration

CREATE TICKET
CREATE ORDER

19. Don't Cancel Completed Orders!




Marley

Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат