I mostly concur - Go really needs TLS - simplifies this sort of thing. You can look at many “complex” Java based server systems and the method calls are far simpler in the common case (especially when using a framework that leverages TLS).
I think a key issue is that most ‘requests’ are not long-enough lived for the cancellation context to be warranted - otherwise the site would be too slow anyway. You see this need in “background jobs” - and still, these jobs are usually per server/application, not per user or per request. Systems that perform time consuming data analysis jobs on behalf of a user are a different case, and they clearly need a way to stop their processing. And yes the ‘not type safe api’ for values is a problem. If Go really wants to promote the context as ubiquitous it should have built-in language support to address these issues (type safety, no need for TLS, required at Go routine creation site, etc.). > On Jan 13, 2019, at 6:35 PM, Space A. <reexist...@gmail.com> wrote: > > I just leave it here > > Context should go away for Go 2 > <https://faiface.github.io/post/context-should-go-away-go2/> > > > > воскресенье, 13 января 2019 г., 22:21:50 UTC+3 пользователь Tamás Gulácsi > написал: > -----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 > <http://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 <mahend...@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 <justin...@gmail.com <>> > > wrote: > > > > > On Mon, Jan 14, 2019, 2:23 AM Mahendra Bhoir <mahend...@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 > > > > > > > > <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 <tgula...@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...@googlegroups.com <>. > > > > > For more options, visit https://groups.google.com/d/optout > > > > > <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...@googlegroups.com <>. > > > > For more options, visit https://groups.google.com/d/optout > > > > <https://groups.google.com/d/optout>. > > > > -- > > Mahendra Bhoir. > > +919545688916 > -----BEGIN PGP SIGNATURE----- > Version: ProtonMail > Comment: https://protonmail.com <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 > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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.