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

tchclient - Add gauntlet to runThrift #162

Merged
merged 39 commits into from
Jun 1, 2016
Merged

Conversation

HelloGrayson
Copy link
Contributor

@HelloGrayson HelloGrayson commented May 31, 2016

  • Refactor parts of crossdock/client/gauntlet/behavior.go to be reusable.
  • Extend crossdock/client/tchclient/thrift.go to include the gauntlet.

@yarpc/golang

@HelloGrayson HelloGrayson changed the title WIP tchclient gauntlet tchclient gauntlet Jun 1, 2016
{
Function: "TestEnum",
Details: "MyNumberz",
// TODO is this a thrift-gen bug?
Copy link
Contributor

@abhinav abhinav Jun 1, 2016

Choose a reason for hiding this comment

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

Not a thrift-gen bug. This is how Apache Thrift generates code for enum constants.

"github.com/yarpc/yarpc-go/crossdock/client/random"
"github.com/yarpc/yarpc-go/crossdock/thrift/gen-go/echo"
"github.com/yarpc/yarpc-go/crossdock/thrift/gen-go/gauntlet_apache"
Copy link
Contributor

Choose a reason for hiding this comment

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

What governs whether you choose to use underscore, hyphen, or no delimiter at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

the leaf package name cannot contain hypens, but directories can. The default output from Apache thrift creates gen-go hence the hyphen (internally, we prefer to use .gen/go).

Ideally package names do not have underscores, but this comes from the filename.

Idiomatic go code doesn't use hypens or underscore normally.

Copy link
Contributor

Choose a reason for hiding this comment

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

No separators are preferred in general. If a separator is needed, underscores have the advantage that they can be part of the package name, so the base name and the package name match. Hyphens cannot be part of the package name so if they're used in the base name, there must be some obvious convention mapping the base name to the package name (yarpc-go => yarpc, thriftrw-go => thriftrw, foo-bar => foo_bar).

See also https://blog.golang.org/package-names

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right, in this case it is generated based on the IDL name. Unavoidable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unavoidable without renaming the file. You can maybe use the namespace directive or one of the thrift compiler options, but I'm not sure.

@abhinav
Copy link
Contributor

abhinav commented Jun 1, 2016

LGTM

@@ -39,21 +44,377 @@ func runThrift(t crossdock.T, call call) {
}
token := random.String(5)

call.Channel.Peers().Add(call.ServerHostPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

optional: instead of calling Peers().Add here, you can instead pass an option to thrift.NewClient,

thrift.NewClient(call.Channel, serverName, &thrift.CallOptions{HostPort: hostPort})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had no idea, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good tip, updated.

@prashantv
Copy link
Contributor

This is great! Suggest updating the title to have more details for the PR. lgtm

@kriskowal
Copy link
Contributor

LG™

@HelloGrayson HelloGrayson changed the title tchclient gauntlet tchclient - Add gauntlet to encoding:thrift Jun 1, 2016
@HelloGrayson HelloGrayson changed the title tchclient - Add gauntlet to encoding:thrift tchclient - Add gauntlet to runThrift Jun 1, 2016
var (
err error
got interface{}
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abhinav @prashantv is it better to just used named return values here rather than a factored var declaration?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, you can use named returns here.

@HelloGrayson HelloGrayson merged commit 0c7ae74 into master Jun 1, 2016
@HelloGrayson HelloGrayson deleted the tchclient-gauntlet branch June 1, 2016 20:25
vyshah pushed a commit that referenced this pull request Nov 14, 2018
Now that nodes represent individual constructors in the graph rather
than the types they provide, we can track on the node whether it was
already called.

This has no value right now but we will need this once we introduce
value groups to ensure that constructors don't get called multiple
times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants