Let's assume the following architecture where
Eventwhich is logged to DB and sent to
WorkerAppprocesses the event, handles failures, etc.
EventCreatorApp --> [ DB ] | ---------> WorkerApp
WorkerApp is done, I want to update the event row in the DB with the outcome of running that event.
My question: Which app should write the outcome to the database?
WorkerApp writes the outcome to the db the logic is nicely decoupled (one app creates events, one app executes events) but I have two apps writing to the db. What's worst, I want to deploy
WorkerApp on an AWS Lambda, and that would mean opening a new connection to the db for each event processed.
EventCreatorApp writes the outcome to the db I don't have any db access problems, but it feels like I'm pushing into
EventCreatorApp some logic that doesn't really belong there, and in general I'm coupling the two apps a bit since
EventCreatorApp would have to wait for a response.
Which solution is best?