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,12 +69,11 @@ func (j *JobJson) Validate() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
realis.Cluster `json:"cluster"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
SchedUrl string `json:"sched_url"`
|
SchedUrl string `json:"sched_url"`
|
||||||
BinTransport bool `json:"bin_transport,omitempty"`
|
Transport string `json:"transport,omitempty"`
|
||||||
JsonTransport bool `json:"json_transport,omitempty"`
|
|
||||||
ClusterConfig *realis.Cluster `json:"cluster"`
|
|
||||||
Debug bool `json:"debug,omitempty"`
|
Debug bool `json:"debug,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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