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.
This commit is contained in:
parent
18ce281252
commit
aefa298ef2
1 changed files with 14 additions and 9 deletions
|
@ -69,13 +69,12 @@ func (j *JobJson) Validate() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Username string `json:"username"`
|
realis.Cluster `json:"cluster"`
|
||||||
Password string `json:"password"`
|
Username string `json:"username"`
|
||||||
SchedUrl string `json:"sched_url"`
|
Password string `json:"password"`
|
||||||
BinTransport bool `json:"bin_transport,omitempty"`
|
SchedUrl string `json:"sched_url"`
|
||||||
JsonTransport bool `json:"json_transport,omitempty"`
|
Transport string `json:"transport,omitempty"`
|
||||||
ClusterConfig *realis.Cluster `json:"cluster"`
|
Debug bool `json:"debug,omitempty"`
|
||||||
Debug bool `json:"debug,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command-line arguments for config and job JSON files.
|
// Command-line arguments for config and job JSON files.
|
||||||
|
@ -127,10 +126,16 @@ func init() {
|
||||||
|
|
||||||
func CreateRealisClient(config *Config) (realis.Realis, error) {
|
func CreateRealisClient(config *Config) (realis.Realis, error) {
|
||||||
var transportOption realis.ClientOption
|
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()
|
transportOption = realis.ThriftBinary()
|
||||||
} else {
|
case "json", "":
|
||||||
transportOption = realis.ThriftJSON()
|
transportOption = realis.ThriftJSON()
|
||||||
|
default:
|
||||||
|
fmt.Println("Invalid transport option provided!")
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
clientOptions := []realis.ClientOption{
|
clientOptions := []realis.ClientOption{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue