Complete the code to define a service boundary that isolates user data.
class UserService: def get_user_profile(self, user_id): return self.[1].fetch_profile(user_id)
The service boundary should access its own database to keep data isolated and prevent coupling.
Complete the code to ensure communication between services uses APIs, not direct database calls.
def get_order_details(order_id): return [1].call('OrderService', order_id)
Using an API Gateway ensures services communicate through defined APIs, reducing coupling.
Fix the error in the service design to avoid tight coupling.
class PaymentService: def process_payment(self, payment_info): # Incorrect: directly accessing OrderService database orders = [1].query_orders(payment_info.order_id) # process payment logic return True
Accessing OrderService via its API avoids direct database coupling.
Fill both blanks to define a service boundary and communication method that prevent coupling.
class InventoryService: def check_stock(self, product_id): stock = self.[1].get_stock(product_id) return stock if stock > 0 else None class OrderService: def place_order(self, product_id): available = [2].check_stock(product_id) if available: # proceed with order return True return False
Both service boundary and communication use the InventoryService API to avoid coupling.
Fill all three blanks to implement a loosely coupled microservice interaction.
class ShippingService: def ship_order(self, order_id): order_info = [1].get_order(order_id) if order_info and order_info.status == [2]: [3].initiate_shipping(order_id) return True return False
ShippingService calls OrderService via API, checks for 'PAID' status, and calls LogisticsService API to ship, avoiding direct database coupling.