Skip to content

Commit

Permalink
fix readme and add some document
Browse files Browse the repository at this point in the history
  • Loading branch information
sillygod committed Jun 16, 2020
1 parent e1666eb commit 2b2f86f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
File renamed without changes.
7 changes: 0 additions & 7 deletions cmd/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@

cache_type in_memory
match_path /
path /tmp/cache

distributed consul {
service_name "cache_server"
addr "127.0.0.1:8500"
health_check ":7777/health"
}

}

Expand Down
3 changes: 1 addition & 2 deletions readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@

** Test Result

The following benchmark is analysized by =wrk -c 50 -d 30s --latency -t 4 http://localhost:9991/pg31674.txt=
the file size is 100KB
The following benchmark is analysized by =wrk -c 50 -d 30s --latency -t 4 http://localhost:9991/pg31674.txt= without log open

| | req/s | latency (50% 90% 99%) |
| proxy + file cache | 13853 | 3.29ms / 4.09ms / 5.26ms |
Expand Down
8 changes: 8 additions & 0 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func NewResponse() *Response {
return r
}

// Header return the header from the upstream response
func (r *Response) Header() http.Header {
return r.HeaderMap
}
Expand Down Expand Up @@ -81,6 +82,7 @@ func (r *Response) writeHeader(b []byte, str string) {
r.WriteHeader(200)
}

// Write writes the upstream's content in the backend's storage
func (r *Response) Write(buf []byte) (int, error) {

// debug.PrintStack()
Expand All @@ -99,26 +101,31 @@ func (r *Response) Write(buf []byte) (int, error) {
return 0, errors.New("No storage provided")
}

// WaitClose waits the response to be closed.
func (r *Response) WaitClose() {
<-r.closedChan
}

// GetReader gets the reader from the setted backend
func (r *Response) GetReader() (io.ReadCloser, error) {
if r.bodyComplete == false {
<-r.bodyCompleteChan
}
return r.body.GetReader()
}

// SetBody sets the backend to body for the further write usage
func (r *Response) SetBody(body backends.Backend) {
r.body = body
r.bodyChan <- struct{}{}
}

// WaitHeaders waits the header to be written
func (r *Response) WaitHeaders() {
<-r.headersChan
}

// WriteHeader keeps the upstream response header
func (r *Response) WriteHeader(code int) {
if r.wroteHeader {
return
Expand Down Expand Up @@ -179,6 +186,7 @@ func isWebSocket(h http.Header) bool {
return false
}

// Flush flushes the backend's storage (currently, only file storage need to call this)
func (r *Response) Flush() {
if !r.wroteHeader {
r.WriteHeader(200)
Expand Down

0 comments on commit 2b2f86f

Please sign in to comment.