Aha! from Failure responses.
We know what to reply when everything runs smoothly.
But, what should the return type be for fallbacks, What should the response be when something goes wrong ?
I was wondering and then Aha!
All the response should packaged in DTOs . Yes All responses finally should look similar.
This is obvious for some, but not for me.
So i wanted to call a HTTP service wrapped in a circuitbreaker. which needs a fallback.
So lo and behold i need to think .
GET /api/v1/product/{id} , suppose this service is shitty and is down. and i need a response.
I want my own service to deal with it, say i get it from my cache only .
so now.
both response should be similar
String id;
String name;
boolean error;
String errorMsg;
}
so , now even if the service is down the recipent as to deal with similar response. and deal with it.,
Comments
Post a Comment