Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple thrift services for tchannel client #103

Merged
merged 4 commits into from
May 24, 2017
Merged

Allow multiple thrift services for tchannel client #103

merged 4 commits into from
May 24, 2017

Conversation

ChuntaoLu
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented May 22, 2017

Coverage Status

Coverage increased (+0.05%) to 70.196% when pulling b135fde on lu.ms into 51262c8 on master.

@Raynos
Copy link
Contributor

Raynos commented May 22, 2017

It might be nice to change our client generation semantics to only generate the methods we need, with shorter names.

If the client-config.json had a mapping of method names to generate, e.g.

{
    config: {
        methods: {
            "Call": "SimpleService::Call"
        }
    }
}

This will reduce the amount of code generated and will allow us to give shroter method names instead of the long form.

// {{.Name}} ...
func (c *{{$clientName}}) {{.Name}}(
// {{title $svc.Name}}{{title .Name}} is a client RPC call for method "{{.Name}}" of thrift service "{{$svc.Name}}"
func (c *{{$clientName}}) {{title $svc.Name}}{{title .Name}}(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method name will get quite long for our generated clients.

@ChuntaoLu
Copy link
Contributor Author

@Raynos Agreed, I have thought about it, but ended up with the simplest solution here. I will try to make it happen.

clientMethodName = method.DownstreamMethod.Name
if e.WorkflowType == "tchannelClient" {
clientMethodName = method.DownstreamService + strings.Title(clientMethodName)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, not sure how it gets in here

@@ -690,6 +691,16 @@ func (g *EndpointGenerator) generateEndpointFile(
strings.Title(method.Name) + "Endpoint"
}

// TODO: http client needs to support multiple thrift services
var clientMethodName string
if method.DownstreamMethod != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can method.DownstreamMethod be nil here? (i don't think it can)

If it can, an error should be thrown here. If it can't, this if should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a non-proxy custom endpoint, it can, and it's not an error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is nil, clientMethodName will be "" after this if. Shouldn't it be an error to render template with "" ClientMethodName?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of clientMethodName is guarded by a downstream existence check, it's only used when downstream exists.

@coveralls
Copy link

coveralls commented May 24, 2017

Coverage Status

Coverage increased (+0.07%) to 73.851% when pulling 0edd034 on lu.ms into f7255d5 on master.

@Raynos
Copy link
Contributor

Raynos commented May 24, 2017

lgtm.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 74.276% when pulling f543e5c on lu.ms into 2e0977b on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 74.276% when pulling f543e5c on lu.ms into 2e0977b on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants