Long-running task design

So far, we've learned about the basics of queuing and how to delay jobs. Now, we're going to design a solution to a problem regarding asynchronous APIs. The problem is that we want to build a system that can handle requests for the following scenarios:

  • The server should save information to the database as one operation.
  • It should send an email to the given email address.
  • It should perform a long-running job and POST the result to a callback. This is known as a web-hook.

Let's say these three operations are asynchronous and long-running. We need a mechanism to facilitate a long-running process that has the following characteristics:

  • The client can fire an API and receive a job ID back.
  • The job is pushed onto a queue ...

Get Hands-On RESTful Web Services with Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.