-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 There should be a "global" or parent Context, which is canceled when the server is going to shut down (e.g. with signal.Notify), and each handler should create a child context with a proper timeout.
And it should watch the request's Context, too, as that's what will be canceled when the client disconnects. github.com/LK4D4/joincontext may help with tis. But if you use the request's Context only with a propert timeout, that's already better than doing nothing. Tamás ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On 2019. January 13., Sunday 19:49, Mahendra Bhoir <mahendra....@gmail.com> wrote: > That makes sense.. So where should declare my context variable? Inside > handler function or in main function As handler itself is a goroutine.. > > On Sun, Jan 13, 2019 at 11:24 PM Justin Israel <justinisr...@gmail.com> wrote: > > > On Mon, Jan 14, 2019, 2:23 AM Mahendra Bhoir <mahendra....@gmail.com> wrote: > > > > > APIs I have written are for mobile applications and request cancellation > > > doesn’t happen much on mobile applications. > > > > What if the mobile client closes the app in the middle of an expensive > > request? > > > > > I think I am little confused with uses of context. > > > > > > I found this page on Internet about context. I this will clear my > > > confusions.. > > > > > > https://www.sohamkamani.com/blog/golang/2018-06-17-golang-using-context-cancellation/#listening-for-the-cancellation-event > > > > > > On Sun, 13 Jan 2019 at 6:24 PM, Tamás Gulácsi <tgulacs...@gmail.com> > > > wrote: > > > > > > > Timing out and cancellation are the main uses of Context. > > > > > > > > How do you cancel processing when the client clises the connection? > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "golang-nuts" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > > > > an email to golang-nuts+unsubscr...@googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > -- > > > Mahendra Bhoir. > > > +919545688916 > > > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "golang-nuts" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > > email to golang-nuts+unsubscr...@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > -- > Mahendra Bhoir. > +919545688916 -----BEGIN PGP SIGNATURE----- Version: ProtonMail Comment: https://protonmail.com wsBcBAEBCAAGBQJcO4+hAAoJELj70Bsqr19tI9QIAIwrPJKrRlALTtOxnDY8 qoLippDAevQxpAzpQYW6w5VN7eDrxdXUrIH1gHGXYJPYOv/J7/i4gbK1txW0 rQaaKpR8JmCY6CDdaQaTVg50XeC3yApFJPEeRZazLztnmKi6HB6PQhgGondA edpsPOQejfLe9KMhN+7RJzVjwWYHYwZXyMIITQT8/jADip3AAZWKojcXFpJq 7MfWfIjru0+tT5+hSfLr8JZpimMwhmOoW8xVeTKmZkXonucky5E3WmJUEPEv 3lcQQVZI3827PLeMKsKd6UpI2x2CcCqLPInIeEzVsDjhWURI2gznWv2Sqj6v T3wS3oVXoJo28sgb9ViyEC0= =1E4l -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
publickey - tamas@gulacsi.eu - 0x78A4747D.asc
Description: application/pgp-keys
publickey - tamas@gulacsi.eu - 0x78A4747D.asc.sig
Description: PGP signature