[ 
https://issues.apache.org/jira/browse/THRIFT-4453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16733166#comment-16733166
 ] 

Can Celasun commented on THRIFT-4453:
-------------------------------------

> If you don't mind sharing and documenting how you accomplished this in such a 
> short time it would really ease the pain of transition.

This was quite a while ago so I don't recall exactly but I believe the whole 
0.11 transition took us not more than a day or two. Sorry, no docs as I don't 
remember any details.

> I understand this is the intended use but can you please point me to where it 
> is being used as such

Nothing is automatically passed, it just allows a developer to pass arbitrary 
values. For example, imagine a thrift HTTP handler like this:


{code:go}
func(w http.ResponseWriter, r *http.Request) {
        var transport thrift.TTransport
        transport = thrift.NewStreamTransport(r.Body, w)
        protocol := protocolFactory.GetProtocol(transport)

        ctx := context.WithValue(context.Background(), "ip", getIP(r))
        processor.Process(ctx, protocol, protocol)
}
{code}

which means you can just use {{ctx.Value("ip").(string)}} in any RPC handler.

> Go generator flag to turn off Context parameter
> -----------------------------------------------
>
>                 Key: THRIFT-4453
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4453
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Go - Compiler
>    Affects Versions: 0.11.0
>            Reporter: Renan DelValle
>            Priority: Minor
>
> It would be worthwhile to be able to pass a argument to the code generator 
> for Go that allows to disable the addition of the Context parameter to each 
> function signature that was included with the 0.11.0 release. This is to 
> avoid backwards incompatible code generation in cases where developers don't 
> require context.
> This flag could be as simple as `-disable-context`



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to