Careeroza
Real World Example
How Big Companies Call Each Other
| Company | Example call | Protocol |
|---|---|---|
| Netflix | Playback API asks the licence service if a title can play in India | gRPC / REST, plus their own client libraries |
| Amazon | Checkout asks the pricing and inventory services before charging | Internal service APIs |
| Uber | Trip service asks pricing for a fare quote | gRPC (Protobuf contracts) |
| Swiggy | Cart asks the restaurant service if the outlet is open | REST/gRPC + Kafka events |
Note: Every one of these calls has a timeout, an error mapping and usually a fallback. Swiggy shows "Restaurant currently not accepting orders" instead of an error page when the call fails.
Swiggy-Style Check Before Checkout
@Component
public class RestaurantClient {
private final RestClient restClient;
public RestaurantClient(RestClient.Builder builder,
@Value("${services.restaurant-url}") String url) {
this.restClient = builder.baseUrl(url).build();
}
public record Availability(Long restaurantId, boolean open, int prepMinutes) {}
public Availability availability(Long restaurantId) {
return restClient.get()
.uri("/api/restaurants/{id}/availability", restaurantId)
.retrieve()
.body(Availability.class);
}
}Example
cart-service checks availability before showing the "Place Order" button:
curl localhost:8090/api/restaurants/42/availabilityExample output
{"restaurantId":42,"open":true,"prepMinutes":18}ShopEase After This Module
client --> order-service :8082 --RestClient--> product-service :8081
| timeouts 2s/3s |
| 404 -> 404, 409 -> 409 |
| down -> 503 |
order_db product_db
Next: hard-coded URLs and many entry points do not scale.
Spring Cloud adds discovery, a gateway and central config.