In a microservice environment there are two services: Service A and Service B.
Service A manages an entity called x
which has one to many relationship with service B's entity called y
When a network request hits to Service A to delete a specific x
, Service A makes an internal network request to service B to validate whether specific x
being used with any y
item.
In a microservice environment, is there a better and more efficient way to handle this kind of request and validation among two services?
Also these options already came to table, however not optimal.
- Managing a cache on Service A about
y
isn't viable. - Managing a key/property on each
x
about whether it's being used or not, was also considered. However there's a development overhead of migrating all the old data with new property. - Let the front-end (webapp) directly calls Service B's validation before hitting to delete. However there's a possibility to have a false positive with the timing.
Delete
means changingstatus
. I didn't mention that part for brevity.