Sobes.tech
Junior — Senior

Reliable access to a slow and unstable service

livecode

Task condition

There is an external service responsible for calculating discounts for clients. Its implementation is an old monolith that works unpredictably: response times can vary from a few seconds to several hours. A mechanism needs to be designed to limit the impact of such delays and make interactions with the monolith more predictable and fault-tolerant.

package main

import (
  "fmt"
  "http"
)

// The function contacts the outdated monolith and can work very slowly.
func fetchDiscount() float64 {
  disc, _ := http.Get("http://discounts.com/my")

  return disc
}

func main() {
  fmt.Printf("Your discount: %v", fetchDiscount())
}