Life-saving AWS EventBridge is worth everything

While building ShareBook, I was stumbling upon a long-running REST call I myself created :). I thought it was the most well defined/sequenced solution ever for sharing a book.

Photo by cottonbro from Pexels
  • then I gather all the users’ tokens where I need to send the notifications
  • create the book in the database
  • add the pictures of the book
  • in case all is well after the previous steps, then a notification is sent to all the (eligible) users
  • then respond OK — 200
  • in parallel, I gather the users’ tokens where to send the notifications
  • then I create the book and add its pictures to the database: for those, I have no choice but to wait until it is successfully done
  • and return directly OK
  • just before returning OK though, for sending the notifications, I just create the event that is triggering the process which is taking care of sending them, still in the background. Those notifications are persisted before being sent in case the service is down while sending

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store