There is a pice of code from server shutdown function. I guess it implements a gracefull shutdown
and it waits for unfinished background jobs and waits for amount of time to finish it. If time exceed it shutdowns anyway.
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
_ = srv.Shutdown(ctx)
Is it right?
I made a dummy handler which makes long database call which is actualy smaller than 10 seconds, but anyway if I stop the server when that database call is still processing then that handler had no chance to finish because the above code finished before - i.e. server stoped earlier.
So what is sence of that time amount in the context.WithTimeout(…) function?