From aefa298ef2a5291c0eaffe2ae6a66e08f73c9595 Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Thu, 12 Jul 2018 21:28:22 -0700 Subject: [PATCH] Embed realis.Cluster. Accept transport as string. Config now embeds realis.Cluster to be backwards compatible with the python client cluster.json file. Changed the type of Transport to string to stay flexible if new transport types come up. JSON is used as the default transport option is not transport is provided with the config. --- examples/jsonClient.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/jsonClient.go b/examples/jsonClient.go index e4f12aa..3e10905 100644 --- a/examples/jsonClient.go +++ b/examples/jsonClient.go @@ -69,13 +69,12 @@ func (j *JobJson) Validate() bool { } type Config struct { - Username string `json:"username"` - Password string `json:"password"` - SchedUrl string `json:"sched_url"` - BinTransport bool `json:"bin_transport,omitempty"` - JsonTransport bool `json:"json_transport,omitempty"` - ClusterConfig *realis.Cluster `json:"cluster"` - Debug bool `json:"debug,omitempty"` + realis.Cluster `json:"cluster"` + Username string `json:"username"` + Password string `json:"password"` + SchedUrl string `json:"sched_url"` + Transport string `json:"transport,omitempty"` + Debug bool `json:"debug,omitempty"` } // Command-line arguments for config and job JSON files. @@ -127,10 +126,16 @@ func init() { func CreateRealisClient(config *Config) (realis.Realis, error) { var transportOption realis.ClientOption - if config.BinTransport { + // Configuring transport protocol. If not transport is provided, then using JSON as the + // default transport protocol. + switch config.Transport { + case "binary": transportOption = realis.ThriftBinary() - } else { + case "json", "": transportOption = realis.ThriftJSON() + default: + fmt.Println("Invalid transport option provided!") + os.Exit(1) } clientOptions := []realis.ClientOption{