[jira] [Created] (THRIFT-4236) Support context in go generated code.
taozle created THRIFT-4236: -- Summary: Support context in go generated code. Key: THRIFT-4236 URL: https://issues.apache.org/jira/browse/THRIFT-4236 Project: Thrift Issue Type: Improvement Components: Go - Compiler, Go - Library Reporter: taozle Since context is widely used in go's community, and there is lots of advantage to use context such as control timeout, carry extra info in one request etc, so is there any plan for this? i just searched the issues but didn't find anything about this. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (THRIFT-4236) Support context in go generated code.
[ https://issues.apache.org/jira/browse/THRIFT-4236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16062841#comment-16062841 ] taozle commented on THRIFT-4236: I don't think the {{THeaderTransport}} is what i want. The {{context}} that i mentioned above is the library {{context}} officially accepted in go1.7 which previously located at {{golang.org/x/net/context}}. Currently, the thrift definition: {code:java} service HelloService { string ping() } {code} will generate code like this: {code:java} type HelloService interface { Ping() (r string, err error) } {code} other framework like grpc will pass a {{context}} for the first param, so the expected output for above definition may looks like: {code:java} type HelloService interface { Ping(ctx Context) (r string, err error) } {code} Adding the {{context}} we can return immediately if current request is already expired: {code:java} func (h *HelloHandler) Ping(ctx Context) { f, cancer := CreateLongTask() rv = make(chan string) go f(rv) // long task select { case <-ctx.Done(): cancer() return // Timeout! case <-rv: // Another heavy work. } } {code} or carry extra info like zipkin span for framework level usage. > Support context in go generated code. > - > > Key: THRIFT-4236 > URL: https://issues.apache.org/jira/browse/THRIFT-4236 > Project: Thrift > Issue Type: Improvement > Components: Go - Compiler, Go - Library >Reporter: taozle > > Since context is widely used in go's community, and there is lots of > advantage to use context such as control timeout, carry extra info in one > request etc, so is there any plan for this? i just searched the issues but > didn't find anything about this. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (THRIFT-4236) Support context in go generated code.
[ https://issues.apache.org/jira/browse/THRIFT-4236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16065827#comment-16065827 ] taozle commented on THRIFT-4236: Hi, [~jensg], I fired a pull request for adding context support in thrift golang server side but it failed tests due to the lack of thirdparty dependency {{golang.org/x/net/context}}, is thirdparty package not allowed in thrift-go? or should we just simple require go >= 1.7? > Support context in go generated code. > - > > Key: THRIFT-4236 > URL: https://issues.apache.org/jira/browse/THRIFT-4236 > Project: Thrift > Issue Type: Improvement > Components: Go - Compiler, Go - Library >Reporter: taozle > > Since context is widely used in go's community, and there is lots of > advantage to use context such as control timeout, carry extra info in one > request etc, so is there any plan for this? i just searched the issues but > didn't find anything about this. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (THRIFT-4236) Support context in go generated code.
[ https://issues.apache.org/jira/browse/THRIFT-4236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16069956#comment-16069956 ] taozle commented on THRIFT-4236: {quote}Could you adjust the build scripts version checks accordingly?{quote} Updated. > Support context in go generated code. > - > > Key: THRIFT-4236 > URL: https://issues.apache.org/jira/browse/THRIFT-4236 > Project: Thrift > Issue Type: Improvement > Components: Go - Compiler, Go - Library >Reporter: taozle > > Since context is widely used in go's community, and there is lots of > advantage to use context such as control timeout, carry extra info in one > request etc, so is there any plan for this? i just searched the issues but > didn't find anything about this. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (THRIFT-4236) Support context in go generated code.
[ https://issues.apache.org/jira/browse/THRIFT-4236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16071878#comment-16071878 ] taozle commented on THRIFT-4236: Awesome! I am considering making this the default behavior in 1.0, any advise? if this make sense, should i work for it now or after 0.11.0 released? > Support context in go generated code. > - > > Key: THRIFT-4236 > URL: https://issues.apache.org/jira/browse/THRIFT-4236 > Project: Thrift > Issue Type: Improvement > Components: Go - Compiler, Go - Library >Reporter: taozle >Assignee: taozle > Fix For: 0.11.0 > > > Since context is widely used in go's community, and there is lots of > advantage to use context such as control timeout, carry extra info in one > request etc, so is there any plan for this? i just searched the issues but > didn't find anything about this. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (THRIFT-4236) Support context in go generated code.
[ https://issues.apache.org/jira/browse/THRIFT-4236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16084196#comment-16084196 ] taozle commented on THRIFT-4236: Maybe i can work on this this weekend or next week if it was not too late, and when will the 0.11 be released? i really hope this feature will be released with 0.11 > Support context in go generated code. > - > > Key: THRIFT-4236 > URL: https://issues.apache.org/jira/browse/THRIFT-4236 > Project: Thrift > Issue Type: Improvement > Components: Go - Compiler, Go - Library >Reporter: taozle >Assignee: taozle > Fix For: 0.11.0 > > > Since context is widely used in go's community, and there is lots of > advantage to use context such as control timeout, carry extra info in one > request etc, so is there any plan for this? i just searched the issues but > didn't find anything about this. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (THRIFT-4260) Go context generation issue. Context is parameter in Interface not in implementation
[ https://issues.apache.org/jira/browse/THRIFT-4260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16097594#comment-16097594 ] taozle commented on THRIFT-4260: The commit is intended to add the context in only server side, and i didn't realize that the client is also _designed to?_ implement the service interface.If this is a design, i will try to fix it. > Go context generation issue. Context is parameter in Interface not in > implementation > > > Key: THRIFT-4260 > URL: https://issues.apache.org/jira/browse/THRIFT-4260 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler >Affects Versions: 0.11.0 >Reporter: Bas van Beek >Assignee: taozle >Priority: Blocker > > Unfortunately the Go library was updated before a new Compiler was released. > Having thrift compiled code be part in a project prior to the thrift context > library addition breaks due to the dependency on the thrift go library. See: > https://github.com/openzipkin/zipkin-go-opentracing/issues/68 > I tried to resolve be installing compiler from latest source but found the > generated source to be incorrect. The generated Go interface for the service > client includes context.Context as the first parameter of the service method. > The generated client implementation however does not. > The following thrift code: > {code:none} > enum ResultCode > { > OK, > TRY_LATER > } > struct LogEntry > { > 1: string category, > 2: string message > } > service Scribe > { > ResultCode Log(1: list messages); > } > {code} > Generated the following Go code: > {code:none} > type Scribe interface { > // Parameters: > // - Messages > Log(ctx context.Context, messages []*LogEntry) (r ResultCode, err error) > } > ... > // Parameters: > // - Messages > func (p *ScribeClient) Log(messages []*LogEntry) (r ResultCode, err error) { > if err = p.sendLog(messages); err != nil { > return > } > return p.recvLog() > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)