mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add options params for the Assign func
This commit is contained in:
parent
356b8048c5
commit
79b0a58132
|
@ -19,7 +19,13 @@ type AssignResult struct {
|
|||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func Assign(server string, count uint64, replication string, collection string, ttl string) (*AssignResult, error) {
|
||||
/*
|
||||
options params meaning:
|
||||
options[0] main data Center
|
||||
options[1] main rack
|
||||
options[2] main data node
|
||||
*/
|
||||
func Assign(server string, count uint64, replication string, collection string, ttl string, options ...string) (*AssignResult, error) {
|
||||
values := make(url.Values)
|
||||
values.Add("count", strconv.FormatUint(count, 10))
|
||||
if replication != "" {
|
||||
|
@ -31,6 +37,31 @@ func Assign(server string, count uint64, replication string, collection string,
|
|||
if ttl != "" {
|
||||
values.Add("ttl", ttl)
|
||||
}
|
||||
|
||||
var dataCenter, rack, dataNode string
|
||||
switch len(options) {
|
||||
case 1:
|
||||
dataCenter = options[0]
|
||||
case 2:
|
||||
dataCenter = options[0]
|
||||
rack = options[1]
|
||||
case 3:
|
||||
dataCenter = options[0]
|
||||
rack = options[1]
|
||||
dataNode = options[2]
|
||||
default:
|
||||
}
|
||||
|
||||
if dataCenter != "" {
|
||||
values.Add("dataCenter", dataCenter)
|
||||
}
|
||||
if rack != "" {
|
||||
values.Add("rack", rack)
|
||||
}
|
||||
if dataNode != "" {
|
||||
values.Add("dataNode", dataNode)
|
||||
}
|
||||
|
||||
jsonBlob, err := util.Post("http://"+server+"/dir/assign", values)
|
||||
glog.V(2).Info("assign result :", string(jsonBlob))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue