Instead of being general I’ll ask the question using my specific examples.
So I have a few serverless projects, each representing a microservice. There are two in particular, the OrderService and RulesEngine. When a new order is create it needs to send it to the rules engine to have any rules applied.
Now there are a few different ways to do this, two of which I considered:
OrderService says the order, publishes a NewOrder event via some message broker (queues, streams etc), RulesEngine picks its, applies the rules, publishes RuleApplied event, OrderService updates order.
OrderService calls ‘applyRules’ on RulesEngine, gets response and saves it.
I know (1) scales better but we went with (2) because this is a MVP and we didn’t want the hassle of configuring SQS etc whatever, dealing with failures etc. It was just easier to have something that fails so we can debug it.
Anyways, how would I test this? I can run the OrderService in offline mode but I don’t have a great way to simulate the call to the RulesEngine. Is there a way to provide a mock RulesEngine lambda at run time?