Reservation

Once the payment callback is fired, we need to create a reservation entity in our booking database. The booking workflow will go through various stages, and this persistent entity will be responsible for maintaining the reservation status for all the microservices involved in the workflow.

The booking service is a REST API, and we will implement it using Gin (which we covered in Chapter 5, Going Distributed). The createReservation API, which is called during the Payment Callback, is defined in the following code:

func createReservation(c *gin.Context) {    var (        reservationDTO HotelReservationDTO        err error        )    if err = c.ShouldBindJSON(&reservationDTO); err == nil {        fmt.Printf("In createReservation : %+v\n", reservationDTO) err = persistReservation(&reservationDTO) ...

Get Hands-On Software Architecture with Golang 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.