Change to protocol buffer for volume-join-masster message

Reduced size to about 1/5 of the previous json format message
This commit is contained in:
Chris Lu
2014-04-21 02:11:10 -07:00
parent 637469e656
commit 1818a2a2da
9 changed files with 388 additions and 46 deletions

View File

@@ -1,6 +1,7 @@
package util
import (
"bytes"
"code.google.com/p/weed-fs/go/glog"
"fmt"
"io/ioutil"
@@ -21,6 +22,21 @@ func init() {
client = &http.Client{Transport: Transport}
}
func PostBytes(url string, body []byte) ([]byte, error) {
r, err := client.Post(url, "application/octet-stream", bytes.NewReader(body))
if err != nil {
glog.V(0).Infoln(err)
return nil, err
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
glog.V(0).Infoln("read post result from", url, err)
return nil, err
}
return b, nil
}
func Post(url string, values url.Values) ([]byte, error) {
r, err := client.PostForm(url, values)
if err != nil {