Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pd-ctl: add config replicate and show all config #573

Merged
merged 13 commits into from
Mar 27, 2017
Merged

Conversation

nolouch
Copy link
Contributor

@nolouch nolouch commented Mar 19, 2017

@@ -115,3 +149,50 @@ func setConfigCommandFunc(cmd *cobra.Command, args []string) {
printResponseError(r)
}
}

func setReplicateConfigCommandFunc(cmd *cobra.Command, args []string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use setConfigCommandFunc directly? I think the implementation code is duplicated here.

value, err = strconv.ParseFloat(args[1], 64)
if err != nil {
value = args[1]
switch k := f.typ; true {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the purpose of this? I

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to convert the value to correct type, like LocationLabels are []string. the marshal need distinguish these.

Copy link
Contributor

@disksing disksing Mar 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer switch f.type here and list all numeric types instead of k <= reflect.Float64.

r, err = http.Post(url, "application/json", bytes.NewBuffer(req))
if path == schedulePrefix {
path = configPrefix
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use schedulePrefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the API setSchedule and getSchedule are not consistent. considering compatible I just adjust it in here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to give up supporting old pd-server.

@disksing
Copy link
Contributor

LGTM.

url := getAddressFromCmd(cmd, schedulePrefix)
var value interface{}
data := make(map[string]interface{})
f, ok := optionRel[opt]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should parse args for different sub commands separately, it is more clear than using reflect here.

IMO, I don't like reflect here.

Copy link
Contributor Author

@nolouch nolouch Mar 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like config set schedule <option> <value> and config set replicas <option> <value>? but we also need to distinguish the field type like string and []string in ReplicationConfig. I think this way is ok, it is no need to adjust when I add a field in config.


url := getAddressFromCmd(cmd, schedulePrefix)
func postDataWithPath(cmd *cobra.Command, args []string, path string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If args len must be 2, use key string, value string instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/postDataWithPath/postConfigDataWithPath/s

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

h.rd.JSON(w, http.StatusInternalServerError, err.Error())
return
}
err = json.Unmarshal(data, &config.Schedule)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we support json.Unmarshal(data, &config) later?

IMO, I prefer check key-value one by one.

Copy link
Contributor Author

@nolouch nolouch Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a more easy way :). the other config no need to dynamic adjust.

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@siddontang siddontang merged commit 6782d36 into master Mar 27, 2017
@siddontang siddontang deleted the shuning/config-all branch March 27, 2017 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants