diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-04-13 23:56:15 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-04-13 23:56:15 -0700 |
| commit | 5878f7c3a1f80b5e831c7259b461e8a58307687c (patch) | |
| tree | 4982299578895293a2f0be2f39aae68c2bf3dcf9 /go/operation | |
| parent | f20ef922fd50ff76b4bb39e61022089f02cc241b (diff) | |
| download | seaweedfs-5878f7c3a1f80b5e831c7259b461e8a58307687c.tar.xz seaweedfs-5878f7c3a1f80b5e831c7259b461e8a58307687c.zip | |
refactor lookup result types into package "operation"
Diffstat (limited to 'go/operation')
| -rw-r--r-- | go/operation/lookup_volume_id.go | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/go/operation/lookup_volume_id.go b/go/operation/lookup_volume_id.go index 2e488353b..7e4f5dd08 100644 --- a/go/operation/lookup_volume_id.go +++ b/go/operation/lookup_volume_id.go @@ -11,12 +11,13 @@ import ( ) type Location struct { - Url string `json:"url"` - PublicUrl string `json:"publicUrl"` + Url string `json:"url,omitempty"` + PublicUrl string `json:"publicUrl,omitempty"` } type LookupResult struct { - Locations []Location `json:"locations"` - Error string `json:"error"` + VolumeId string `json:"volumeId,omitempty"` + Locations []Location `json:"locations,omitempty"` + Error string `json:"error,omitempty"` } func Lookup(server string, vid string) (*LookupResult, error) { @@ -51,3 +52,20 @@ func LookupFileId(server string, fileId string) (fullUrl string, err error) { } return "http://" + lookup.Locations[rand.Intn(len(lookup.Locations))].PublicUrl + "/" + fileId, nil } + +func LookupVolumeIds(server string, vids []string) ([]LookupResult, error) { + values := make(url.Values) + for _, vid := range vids { + values.Add("volumeId", vid) + } + jsonBlob, err := util.Post("http://"+server+"/vol/lookup", values) + if err != nil { + return nil, err + } + var ret []LookupResult + err = json.Unmarshal(jsonBlob, &ret) + if err != nil { + return nil, err + } + return ret, nil +} |
