snowflakedb / gosnowflake

Go Snowflake Driver
Apache License 2.0
285 stars 116 forks source link

Proposed goroutine wrapper solution #1157

Closed madisonchamberlain closed 1 month ago

madisonchamberlain commented 1 month ago

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 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