-
Notifications
You must be signed in to change notification settings - Fork 103
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
Conversation
{ | ||
Function: "TestEnum", | ||
Details: "MyNumberz", | ||
// TODO is this a thrift-gen bug? |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
LGTM |
@@ -39,21 +44,377 @@ func runThrift(t crossdock.T, call call) { | |||
} | |||
token := random.String(5) | |||
|
|||
call.Channel.Peers().Add(call.ServerHostPort) |
There was a problem hiding this comment.
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})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had no idea, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tip, updated.
This is great! Suggest updating the title to have more details for the PR. lgtm |
LG™ |
var ( | ||
err error | ||
got interface{} | ||
) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.
crossdock/client/gauntlet/behavior.go
to be reusable.crossdock/client/tchclient/thrift.go
to include the gauntlet.@yarpc/golang