Multiple ctx created from context.Background() #37
-
Hey, I'd like to ask what is your way to go for interacting with I had in mind that it was a good idea to have a But it seems you don't necessarily follow this pattern. For instance, you instantiate another context from If something unfortunate happens in the Thanks a lot for the clarification. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Good question. The The reason I like to manage an internal context for If you pass a cancelable context from |
Beta Was this translation helpful? Give feedback.
Good question. The
context
is typically request-based so it's generated from the HTTP server and that's what's used for most of the code inwtf
. Typically the exception is background processing like what thesqlite.DB.monitor()
function is doing.The reason I like to manage an internal context for
DB
instead of using one frommain()
is that it lets me control the shutdown process better. For example, I typically want to wait for the signal from the OS to shutdown and then shutdown the HTTP server and then shutdown the DB. That allows me to gracefully close open connections on the HTTP server whereas closing the DB first would immediately return errors on open connections.If you pass a ca…