Browse Source

rafthttp: make ConnReadLimitByte private and add comment

Xiang Li 10 years ago
parent
commit
080c11d14e
1 changed files with 9 additions and 3 deletions
  1. 9 3
      rafthttp/http.go

+ 9 - 3
rafthttp/http.go

@@ -29,7 +29,13 @@ import (
 )
 )
 
 
 const (
 const (
-	ConnReadLimitByte = 64 * 1024
+	// connReadLimitByte limits the number of bytes
+	// a single read can read out.
+	// 
+	// 64KB should be large enough for not causing
+	// throughput bottleneck as well as small enough
+	// for not causing a read timeout.
+	connReadLimitByte = 64 * 1024
 )
 )
 
 
 var (
 var (
@@ -94,8 +100,8 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	}
 	}
 
 
 	// Limit the data size that could be read from the request body, which ensures that read from
 	// Limit the data size that could be read from the request body, which ensures that read from
-	// connection will not time out accidentally due to possible block in underlying implementation.
-	limitedr := pioutil.NewLimitedBufferReader(r.Body, ConnReadLimitByte)
+	// connection will not time out accidentally due to possible blocking in underlying implementation.
+	limitedr := pioutil.NewLimitedBufferReader(r.Body, connReadLimitByte)
 	b, err := ioutil.ReadAll(limitedr)
 	b, err := ioutil.ReadAll(limitedr)
 	if err != nil {
 	if err != nil {
 		plog.Errorf("failed to read raft message (%v)", err)
 		plog.Errorf("failed to read raft message (%v)", err)