As discussed in slack, I would like to have the ability to wrap a panic in a go routine, rather than letting it crash our service. We want to simply use the recover function to grab the panic, and then send that panic to sentry (the service we use to track errors). For us this would make debugging easier and more productive.
I have added a variable GoroutineWrapper which is a function that takes in a function. I call this variable around all of the goroutines that are spawned throughout the codebase. On init, a caller can provide a function which does what it wants to wrap goroutines. If nothing is specified, we fallback on defaultDoesNothing which just calls the goroutine with no wrapping/handling as is happening now. Please let me know your thoughts, I am happy to change anything!
Checklist
[X] Created tests which fail without the change (if possible)
[ ] Extended the README / documentation, if necessary - I will do this once we are in a state of knowing for sure how we want this to look/if this is something we want to do
Description
As discussed in slack, I would like to have the ability to wrap a panic in a go routine, rather than letting it crash our service. We want to simply use the recover function to grab the panic, and then send that panic to sentry (the service we use to track errors). For us this would make debugging easier and more productive.
I have added a variable
GoroutineWrapper
which is a function that takes in a function. I call this variable around all of the goroutines that are spawned throughout the codebase. On init, a caller can provide a function which does what it wants to wrap goroutines. If nothing is specified, we fallback ondefaultDoesNothing
which just calls the goroutine with no wrapping/handling as is happening now. Please let me know your thoughts, I am happy to change anything!Checklist