December 2018
Intermediate to advanced
500 pages
12h 19m
English
Sometimes a part of message processing doesn't need to produce any output that is immediately needed. For example, when a ticket is booked and the payment is made, it's OK to get Ticket booked successfully! to the user, while sending them a detailed itinerary through email; we don't need to block the client on the book ticket API until the email is sent.
The background worker pattern solves such situations by enabling a component to delegate work to other components that work in the background.
The worker.go and worker_test.go file (https://github.com/cookingkode/worker) is an example of a generic framework where woker goroutines accept work of the following type:
type Work struct { Key string Args interface{} ...Read now
Unlock full access