Skip to content

Commit

Permalink
check that transport is always specified when calling thrift.NewClient
Browse files Browse the repository at this point in the history
Summary:
check that transport is always specified when calling thrift.NewClient

This way we can be sure that thrift.NewClient is never called without thrift.WithHeader or thrift.WithUpgradeToRocket

We can then be sure that we have upgraded all users of thrift.WithHeader to thrift.WithUpgradeToRocket, when we are ready to fully roll out the rocket client.

Reviewed By: echistyakov

Differential Revision: D63324777

fbshipit-source-id: cc3fa497fae1ec587e637f4d8c4908d48236c26c
  • Loading branch information
awalterschulze authored and facebook-github-bot committed Sep 30, 2024
1 parent d74c278 commit 279da57
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion thrift/lib/go/thrift/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,17 @@ func newDefaultPersistentHeaders() map[string]string {
func newOptions(opts ...ClientOption) (*clientOptions, error) {
res := &clientOptions{
protocol: types.ProtocolIDCompact,
transport: TransportIDHeader,
transport: TransportIDUnknown,
persistentHeaders: newDefaultPersistentHeaders(),
}
for _, opt := range opts {
if err := opt(res); err != nil {
return nil, err
}
}
if res.transport == TransportIDUnknown {
panic(NewTransportException(types.NOT_SUPPORTED, "no transport specified! Please use thrift.WithHeader() or thrift.WithUpgradeToRocket() in the thrift.NewClient call"))
}
return res, nil
}

Expand Down

0 comments on commit 279da57

Please sign in to comment.