Re: [go-nuts] Re: adding context.Context to new code

2017-05-15 Thread mhhcbon
+1 for any feedback. > One issue was libraries that were used both in paths from http requests (so they needed the context propagated through them) but were also used in places where their callers (starting at main) didn't have any contexts at all yup. Imagine also in the middle of the call

Re: [go-nuts] Re: adding context.Context to new code

2017-05-14 Thread 温博格
the comment was for libraries without context parameters but which would need to have them added. On Sun, May 14, 2017 at 11:46 AM, Sameer Ajmani wrote: > Specifically: don't pass nil Contexts. They are not valid, and most code > that uses Contexts don't check for nil and

Re: [go-nuts] Re: adding context.Context to new code

2017-05-14 Thread Sameer Ajmani
Specifically: don't pass nil Contexts. They are not valid, and most code that uses Contexts don't check for nil and will panic. On Sun, May 14, 2017 at 11:43 AM Sameer Ajmani wrote: > Generally I'd suggest passing context.Background() when calling functions > that need a

Re: [go-nuts] Re: adding context.Context to new code

2017-05-14 Thread Sameer Ajmani
Generally I'd suggest passing context.Background() when calling functions that need a context from main or tests. On Sat, May 13, 2017 at 8:27 AM Peter Weinberger (温博格) wrote: > Hi. I was one of the people who failed in an attempt to auto-insert > contexts in all of google3. I

Re: [go-nuts] Re: adding context.Context to new code

2017-05-13 Thread 温博格
Hi. I was one of the people who failed in an attempt to auto-insert contexts in all of google3. I no longer remember all the obstacles I failed to overcome, but would encourage others to take on the project. One issue was libraries that were used both in paths from http requests (so they needed

Re: [go-nuts] Re: adding context.Context to new code

2017-05-13 Thread mhhcbon
A reference i found about "reactive programming" https://github.com/dsyer/reactive-notes/blob/master/intro.adoc Hope this introduced the concept correctly, thanks for pointing that. Following are only some thoughts, Two things surprising here, 1/ a programmer prefers not to solve a problem 2/

Re: [go-nuts] Re: adding context.Context to new code

2017-05-12 Thread Henrik Johansson
With the whole "Reactive" movement thread locals have started to vanish at least in the Java ecosystem. I agree with Sameer that, while convenient, it comes with a whole set of obscure bugs. On Fri, May 12, 2017, 14:57 Sameer Ajmani wrote: > Hmm, I'm not finding good

Re: [go-nuts] Re: adding context.Context to new code

2017-05-12 Thread Sameer Ajmani
Hmm, I'm not finding good open-source examples of ThreadLocal context propagation in C++ and Java. My experience with this is based on what Google uses internally. Perhaps someone more familiar with context use (tracing?) outside Google can chime in? +Jaana Burcu Dogan On Thu,

Re: [go-nuts] Re: adding context.Context to new code

2017-05-11 Thread mhhcbon
thanks, ..integrating Context into the runtime.. 50% runtime, 50% syntax with explicit contextualization. ..The flow of request processing in Go may include multiple goroutines and may move across channels; yes big ? mark here. might the 50% of an handy and explicit syntax help with it?

Re: [go-nuts] Re: adding context.Context to new code

2017-05-11 Thread Sameer Ajmani
I think you are asking whether we considered integrating Context into the runtime, so that it does not need to be passed explicitly. Yes, we discussed this, but decided against it. The flow of request processing in Go may include multiple goroutines and may move across channels; we decided an

Re: [go-nuts] Re: adding context.Context to new code

2017-05-11 Thread mhhcbon
Thanks a lot! Might i guess and try to generalize your explanations into "we tried to write a plumber for all cases possible" Which matters a lot, in my humble opinion. At least for the various reasons you put there, simply put, because it seems not technically achievable. Still i m happy you

Re: [go-nuts] Re: adding context.Context to new code

2017-05-10 Thread Sameer Ajmani
Our approach was to identify function calls that consume a Context (indicated by a call to context.TODO in the function body) and function calls that provide a Context (such as RPC and HTTP handlers). Then we use the guru callgraph tool to find all call paths from context providers to context

Re: [go-nuts] Re: adding context.Context to new code

2017-05-09 Thread mhhcbon
> I've done a limited form of this using awk ;-) if you have a minute, can you tell more about what limited you in your attempts and which trade made you stop (guessing), if any ? Do you still think it be awesome ? Or have you made your mind to an opposite position ? if so, For which

Re: [go-nuts] Re: adding context.Context to new code

2017-05-09 Thread Sameer Ajmani
The eg tool can execute simple refactoring steps, but automating context plumbing through a chain of calls is an open problem. Alan Donovan put some thought into this a few years ago, and I've done a limited form of this using awk ;-) On Tue, May 9, 2017 at 6:10 AM wrote: > I

[go-nuts] Re: adding context.Context to new code

2017-05-09 Thread mhhcbon
I want something similar too. Automatic and smart insertion of context args in a chain of calls. Methods signature updates are easy, but how to appropriately insert context check in the ast ? I m not sure yet. >The difficulty here seems to differentiate intra package calls from calls to