Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

go fmt

  • Loading branch information...
commit c007a256902d51d9f512b7beaaf12535fc775a49 1 parent e8c1047
@titanous titanous authored
View
2  buffer_pool.go
@@ -34,7 +34,7 @@ func newBufferPool(poolSize, bufferSize int) *bufferPool {
}
}
-// Take a buffer from the pool and set
+// Take a buffer from the pool and set
// it up to read from r
func (p *bufferPool) take(r io.Reader) (bpe *bufferPoolEntry) {
select {
View
10 filter.go
@@ -4,15 +4,15 @@ import (
"net/http"
)
-// Filter incomming requests and optionally return a response or nil.
+// Filter incomming requests and optionally return a response or nil.
// Filters are chained together into a flow (the Pipeline) which will terminate
-// if the Filter returns a response.
+// if the Filter returns a response.
type RequestFilter interface {
FilterRequest(req *Request) *http.Response
}
// Helper to create a Filter by just passing in a func
-// filter = NewRequestFilter(func(req *Request) *http.Response {
+// filter = NewRequestFilter(func(req *Request) *http.Response {
// req.Headers.Add("X-Falcore", "is_cool")
// return
// })
@@ -32,13 +32,13 @@ func (f *genericRequestFilter) FilterRequest(req *Request) *http.Response {
// Filter outgoing responses. This can be used to modify the response
// before it is sent. Modifying the request at this point will have no
-// effect.
+// effect.
type ResponseFilter interface {
FilterResponse(req *Request, res *http.Response)
}
// Helper to create a Filter by just passing in a func
-// filter = NewResponseFilter(func(req *Request, res *http.Response) {
+// filter = NewResponseFilter(func(req *Request, res *http.Response) {
// // some crazy response magic
// return
// })
View
6 pipeline.go
@@ -15,12 +15,12 @@ import (
// If no response is generated by any Filters a default 404 response is
// returned.
//
-// The RequestDoneCallback (if set) will be called after the request
+// The RequestDoneCallback (if set) will be called after the request
// has completed. The finished request object will be passed to
// the FilterRequest method for inspection. Changes to the request
// will have no effect and the return value is ignored.
//
-//
+//
type Pipeline struct {
Upstream *list.List
Downstream *list.List
@@ -35,7 +35,7 @@ func NewPipeline() (l *Pipeline) {
}
// Pipelines are also RequestFilters... wacky eh?
-// Be careful though because a Pipeline will always returns a
+// Be careful though because a Pipeline will always returns a
// response so no Filters after a Pipeline filter will be run.
func (p *Pipeline) FilterRequest(req *Request) *http.Response {
return p.execute(req)
View
40 request.go
@@ -13,30 +13,30 @@ import (
)
// Request wrapper
-//
-// The request is wrapped so that useful information can be kept
-// with the request as it moves through the pipeline.
+//
+// The request is wrapped so that useful information can be kept
+// with the request as it moves through the pipeline.
//
// A pointer is kept to the originating Connection.
//
-// There is a unique ID assigned to each request. This ID is not
-// globally unique to keep it shorter for logging purposes. It is
-// possible to have duplicates though very unlikely over the period
+// There is a unique ID assigned to each request. This ID is not
+// globally unique to keep it shorter for logging purposes. It is
+// possible to have duplicates though very unlikely over the period
// of a day or so. It is a good idea to log the ID in any custom
// log statements so that individual requests can easily be grepped
// from busy log files.
//
-// Falcore collects performance statistics on every stage of the
+// Falcore collects performance statistics on every stage of the
// pipeline. The stats for the request are kept in PipelineStageStats.
// This structure will only be complete in the Request passed to the
// pipeline RequestDoneCallback. Overhead will only be available in
// the RequestDoneCallback and it's the difference between the total
// request time and the sums of the stage times. It will include things
// like pipeline iteration and the stat collection itself.
-//
+//
// See falcore.PipelineStageStat docs for more info.
-//
-// The Signature is also a cool feature. See the
+//
+// The Signature is also a cool feature. See the
type Request struct {
ID string
StartTime time.Time
@@ -64,7 +64,7 @@ func newRequest(request *http.Request, conn net.Conn, startTime time.Time) *Requ
}
// create a semi-unique id to track a connection in the logs
// ID is the least significant decimal digits of time with some randomization
- // the last 3 zeros of time.Nanoseconds appear to always be zero
+ // the last 3 zeros of time.Nanoseconds appear to always be zero
var ut = fReq.StartTime.UnixNano()
fReq.ID = fmt.Sprintf("%010x", (ut-(ut-(ut%1e12)))+int64(rand.Intn(999)))
fReq.PipelineStageStats = list.New()
@@ -73,7 +73,7 @@ func newRequest(request *http.Request, conn net.Conn, startTime time.Time) *Requ
}
// Returns a completed falcore.Request and response after running the single filter stage
-// The PipelineStageStats is completed in the returned Request
+// The PipelineStageStats is completed in the returned Request
// The falcore.Request.Connection and falcore.Request.RemoteAddr are nil
func TestWithRequest(request *http.Request, filter RequestFilter, context map[string]interface{}) (*Request, *http.Response) {
r := newRequest(request, nil, time.Now())
@@ -119,16 +119,16 @@ func (fReq *Request) finishCommon() {
// any given time, the Signature is a crc32 sum of all the finished
// pipeline stages combining PipelineStageStat.Name and PipelineStageStat.Status.
// This gives a unique signature for each unique path through the pipeline.
-// To modify the signature for your own use, just set the
+// To modify the signature for your own use, just set the
// request.CurrentStage.Status in your RequestFilter or ResponseFilter.
func (fReq *Request) Signature() string {
return fmt.Sprintf("%X", fReq.pipelineHash.Sum32())
}
-// Call from RequestDoneCallback. Logs a bunch of information about the
-// request to the falcore logger. This is a pretty big hit to performance
-// so it should only be used for debugging or development. The source is a
-// good example of how to get useful information out of the Request.
+// Call from RequestDoneCallback. Logs a bunch of information about the
+// request to the falcore logger. This is a pretty big hit to performance
+// so it should only be used for debugging or development. The source is a
+// good example of how to get useful information out of the Request.
func (fReq *Request) Trace() {
reqTime := TimeDiff(fReq.StartTime, fReq.EndTime)
req := fReq.HttpRequest
@@ -147,11 +147,11 @@ func (fReq *Request) finishRequest() {
fReq.Overhead = fReq.EndTime.Sub(fReq.StartTime) - fReq.piplineTot
}
-// Container for keeping stats per pipeline stage
+// Container for keeping stats per pipeline stage
// Name for filter stages is reflect.TypeOf(filter).String()[1:] and the Status is 0 unless
// it is changed explicitly in the Filter or Router.
-//
-// For the Status, the falcore library will not apply any specific meaning to the status
+//
+// For the Status, the falcore library will not apply any specific meaning to the status
// codes but the following are suggested conventional usages that we have found useful
//
// type PipelineStatus byte
View
4 server.go
@@ -231,8 +231,8 @@ func (srv *Server) handler(c net.Conn) {
res.Close = true
default:
}
- // The res.Write omits Content-length on 0 length bodies, and by spec,
- // it SHOULD. While this is not MUST, it's kinda broken. See sec 4.4
+ // The res.Write omits Content-length on 0 length bodies, and by spec,
+ // it SHOULD. While this is not MUST, it's kinda broken. See sec 4.4
// of rfc2616 and a 200 with a zero length does not satisfy any of the
// 5 conditions if Connection: keep-alive is set :(
// I'm forcing chunked which seems to work because I couldn't get the
View
2  server_windows.go
@@ -12,4 +12,4 @@ func (srv *Server) setupNonBlockingListener(err error, l *net.TCPListener) error
func (srv *Server) cycleNonBlock(c net.Conn) {
// nuthin
-}
+}
View
2  string_body_test.go
@@ -82,7 +82,7 @@ func BenchmarkStringBody(b *testing.B) {
io.CopyN(ioutil.Discard, req.HttpRequest.Body, req.HttpRequest.ContentLength)
req.HttpRequest.Body .Close()
io.CopyN(ioutil.Discard, req.HttpRequest.Body, req.HttpRequest.ContentLength)
- req.HttpRequest.Body .Close()
+ req.HttpRequest.Body .Close()
*/
b.StopTimer()
}

0 comments on commit c007a25

Please sign in to comment.
Something went wrong with that request. Please try again.