Moving from the Thrift JSON protocol to the Thrift Binary protocol by default. Realis config now holds transport and Protocol factory for impreoved flexibility. Renamed realis_test to reflect the true nature of the test along with a minor fix for an API change.
This commit is contained in:
parent
2c7dd3468f
commit
5f155f4337
2 changed files with 8 additions and 9 deletions
15
realis.go
15
realis.go
|
@ -55,18 +55,13 @@ type realisClient struct {
|
||||||
// Wrap object to provide future flexibility
|
// Wrap object to provide future flexibility
|
||||||
type RealisConfig struct {
|
type RealisConfig struct {
|
||||||
transport thrift.TTransport
|
transport thrift.TTransport
|
||||||
|
protoFactory thrift.TProtocolFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new Client with a default transport layer
|
// Create a new Client with a default transport layer
|
||||||
func NewClient(config RealisConfig) Realis {
|
func NewClient(config RealisConfig) Realis {
|
||||||
|
|
||||||
httpTrans := (config.transport).(*thrift.THttpClient)
|
|
||||||
httpTrans.SetHeader("User-Agent", "GoRealis v1.0.4")
|
|
||||||
|
|
||||||
protocolFactory := thrift.NewTJSONProtocolFactory()
|
|
||||||
|
|
||||||
return realisClient{
|
return realisClient{
|
||||||
client: aurora.NewAuroraSchedulerManagerClientFactory(config.transport, protocolFactory)}
|
client: aurora.NewAuroraSchedulerManagerClientFactory(config.transport, config.protoFactory)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a default configuration of the transport layer, requires a URL to test connection with.
|
// Create a default configuration of the transport layer, requires a URL to test connection with.
|
||||||
|
@ -89,8 +84,12 @@ func NewDefaultConfig(url string, timeoutms int) (RealisConfig, error) {
|
||||||
fmt.Fprintln(os.Stderr)
|
fmt.Fprintln(os.Stderr)
|
||||||
return RealisConfig{}, errors.Wrapf(err, "Error opening connection to %s", url)
|
return RealisConfig{}, errors.Wrapf(err, "Error opening connection to %s", url)
|
||||||
}
|
}
|
||||||
|
httpTrans := (trans).(*thrift.THttpClient)
|
||||||
|
httpTrans.SetHeader("Accept", "application/vnd.apache.thrift.binary")
|
||||||
|
httpTrans.SetHeader("Content-Type", "application/vnd.apache.thrift.binary")
|
||||||
|
httpTrans.SetHeader("User-Agent", "GoRealis v1.0.4")
|
||||||
|
|
||||||
return RealisConfig{transport: trans}, nil
|
return RealisConfig{transport: trans, protoFactory: thrift.NewTBinaryProtocolFactoryDefault()}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ var thermosPayload []byte
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// New configuration to connect to Vagrant image
|
// New configuration to connect to Vagrant image
|
||||||
config, err := NewDefaultConfig("http://192.168.33.7:8081")
|
config, err := NewDefaultConfig("http://192.168.33.7:8081",10000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Please run vagrant box before running test suite")
|
fmt.Println("Please run vagrant box before running test suite")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
Loading…
Add table
Add a link
Reference in a new issue