diff --git a/realis.go b/realis.go index 59f614f..ae6ca95 100644 --- a/realis.go +++ b/realis.go @@ -55,18 +55,13 @@ type realisClient struct { // Wrap object to provide future flexibility type RealisConfig struct { transport thrift.TTransport + protoFactory thrift.TProtocolFactory } // Create a new Client with a default transport layer func NewClient(config RealisConfig) Realis { - - httpTrans := (config.transport).(*thrift.THttpClient) - httpTrans.SetHeader("User-Agent", "GoRealis v1.0.4") - - protocolFactory := thrift.NewTJSONProtocolFactory() - 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. @@ -89,8 +84,12 @@ func NewDefaultConfig(url string, timeoutms int) (RealisConfig, error) { fmt.Fprintln(os.Stderr) 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 } diff --git a/realis_test.go b/realis_e2e_test.go similarity index 97% rename from realis_test.go rename to realis_e2e_test.go index 329abbf..a7e4b94 100644 --- a/realis_test.go +++ b/realis_e2e_test.go @@ -28,7 +28,7 @@ var thermosPayload []byte func TestMain(m *testing.M) { // 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 { fmt.Println("Please run vagrant box before running test suite") os.Exit(1)