I'd appreciate some feedback on a basic program for a serverless function which does: 1. parses / validates event input 2. conditionally skips / returns early sometimes based on parsed data 3. processes / sends the one that weren't skipped somehow (not shown) 4. logs errors and then throws them to let the serverless platform know about it (which will handle any retry / dead letter policy for us)
There are some improvements I had in mind but had trouble implementing... 1. How would I implement this using pipe instead of gen? (both for my own understanding, and to discuss preferred style with my team) 2. Could I structure the 'conditional skipping' better? I tried adding
Effect.when
Effect.when
when trying to make a piped version, couldn't get returned types to match up everywhere needed. Should I deal with it as a list of events of length 1 and use filtering somehow instead? 3. Should I use an Exit? It sounds like that's meant for at the top level of an application, but in the context of a serverless function handler I would always want to throw errors which reach the top, since we're not receiving batches of events that could partially fail.