Permalink
Browse files

updated to weekly 2012-01-20

  • Loading branch information...
1 parent d3982a3 commit 8eb6578d98b1d270b43fa41b35b659e6727f05b2 Dave Grijalva committed with gnanderson Jan 24, 2012
View
16 compression/compression.go
@@ -1,14 +1,14 @@
package compression
import (
- "http"
- "strings"
"bytes"
- "io"
- "os"
- "compress/gzip"
"compress/flate"
+ "compress/gzip"
"falcore"
+
+ "io"
+ "net/http"
+ "strings"
)
var DefaultTypes = []string{"text/plain", "text/html", "application/json", "text/xml"}
@@ -75,7 +75,7 @@ func (c *Filter) FilterResponse(request *falcore.Request, res *http.Response) {
// Perform compression
r := make([]byte, 1024)
- var err os.Error
+ var err error
var i int
for err == nil {
i, err = res.Body.Read(r)
@@ -96,11 +96,11 @@ func (c *Filter) FilterResponse(request *falcore.Request, res *http.Response) {
type filteredBody bytes.Buffer
-func (b *filteredBody) Read(byt []byte) (int, os.Error) {
+func (b *filteredBody) Read(byt []byte) (int, error) {
i, err := (*bytes.Buffer)(b).Read(byt)
return i, err
}
-func (b filteredBody) Close() os.Error {
+func (b filteredBody) Close() error {
return nil
}
View
18 compression/compression_test.go
@@ -1,19 +1,19 @@
package compression
import (
- "falcore"
- "http"
"bufio"
- "testing"
- "os"
+ "bytes"
+ "compress/flate"
+ "compress/gzip"
+
+ "falcore"
"fmt"
- "path"
"io"
"io/ioutil"
- "bytes"
- "compress/gzip"
- "compress/flate"
"net"
+ "net/http"
+ "path"
+ "testing"
"time"
)
@@ -159,7 +159,7 @@ func readfile(path string) []byte {
return nil
}
-func get(p string, accept string) (r *http.Response, err os.Error) {
+func get(p string, accept string) (r *http.Response, err error) {
var conn net.Conn
if conn, err = net.Dial("tcp", fmt.Sprintf("localhost:%v", port())); err == nil {
req, _ := http.NewRequest("GET", fmt.Sprintf("http://%v", path.Join(fmt.Sprintf("localhost:%v/", port()), p)), nil)
View
3 etag/etag.go
@@ -1,8 +1,8 @@
package etag
import (
- "http"
"falcore"
+ "net/http"
)
// falcore/etag.Filter is a falcore.ResponseFilter that matches
@@ -16,7 +16,6 @@ import (
// clients are well behaved.
//
type Filter struct {
-
}
func (f *Filter) FilterResponse(request *falcore.Request, res *http.Response) {
View
16 etag/etag_test.go
@@ -1,17 +1,17 @@
package etag
import (
+ "bufio"
+ "bytes"
"falcore"
- "time"
- "http"
- "testing"
- "os"
- "net"
"fmt"
- "bufio"
+
"io"
+ "net"
+ "net/http"
"path"
- "bytes"
+ "testing"
+ "time"
)
var srv *falcore.Server
@@ -99,7 +99,7 @@ var testData = []struct {
},
}
-func get(p string, etag string) (r *http.Response, err os.Error) {
+func get(p string, etag string) (r *http.Response, err error) {
var conn net.Conn
if conn, err = net.Dial("tcp", fmt.Sprintf("localhost:%v", port())); err == nil {
req, _ := http.NewRequest("GET", fmt.Sprintf("http://%v", path.Join(fmt.Sprintf("localhost:%v/", port()), p)), nil)
View
4 examples/basic_file_server/server.go
@@ -3,11 +3,11 @@ package main
import (
"flag"
"fmt"
- "http"
+ "net/http"
"falcore"
- "falcore/static_file"
"falcore/compression"
+ "falcore/static_file"
)
// Command line options
View
2 examples/hello_world/hello_world.go
@@ -1,9 +1,9 @@
package main
import (
- "http"
"flag"
"fmt"
+ "net/http"
"falcore"
)
View
8 examples/hot_restart/hot_restart.go
@@ -2,11 +2,11 @@ package main
import (
"falcore"
- "fmt"
- "http"
"flag"
- "os/signal"
+ "fmt"
+ "net/http"
"os"
+ "os/signal"
"syscall"
)
@@ -64,7 +64,7 @@ func childReady(srv *falcore.Server) {
// setup and fork/exec myself. Make sure to keep open important FD's that won't get re-created by the child
// specifically, std* and your listen socket
-func forker(srv *falcore.Server) (pid int, err int) {
+func forker(srv *falcore.Server) (pid int, err error) {
fmt.Printf("Forking now with socket: %v\n", srv.SocketFd())
mypath := os.Args[0]
args := []string{mypath, "-socket", fmt.Sprintf("%v", srv.SocketFd())}
View
2 filter.go
@@ -1,7 +1,7 @@
package falcore
import (
- "http"
+ "net/http"
)
// Filter incomming requests and optionally return a response or nil.
View
31 logger.go
@@ -1,8 +1,9 @@
package falcore
import (
+ "errors"
"log"
- "os"
+ "time"
)
// I really want to use log4go... but i need to support falling back to standard (shitty) logger :(
@@ -14,9 +15,9 @@ type Logger interface {
Debug(arg0 interface{}, args ...interface{})
Trace(arg0 interface{}, args ...interface{})
Info(arg0 interface{}, args ...interface{})
- Warn(arg0 interface{}, args ...interface{}) os.Error
- Error(arg0 interface{}, args ...interface{}) os.Error
- Critical(arg0 interface{}, args ...interface{}) os.Error
+ Warn(arg0 interface{}, args ...interface{}) error
+ Error(arg0 interface{}, args ...interface{}) error
+ Critical(arg0 interface{}, args ...interface{}) error
}
var logger Logger = NewStdLibLogger()
@@ -26,8 +27,8 @@ func SetLogger(newLogger Logger) {
}
// Helper for calculating times
-func TimeDiff(startTime int64, endTime int64) float32 {
- return float32(endTime-startTime) / 1.0e9
+func TimeDiff(startTime time.Time, endTime time.Time) float32 {
+ return float32(endTime.Sub(startTime)) / 1.0e9
}
// Global Logging
@@ -51,15 +52,15 @@ func Info(arg0 interface{}, args ...interface{}) {
logger.Info(arg0, args...)
}
-func Warn(arg0 interface{}, args ...interface{}) os.Error {
+func Warn(arg0 interface{}, args ...interface{}) error {
return logger.Warn(arg0, args...)
}
-func Error(arg0 interface{}, args ...interface{}) os.Error {
+func Error(arg0 interface{}, args ...interface{}) error {
return logger.Error(arg0, args...)
}
-func Critical(arg0 interface{}, args ...interface{}) os.Error {
+func Critical(arg0 interface{}, args ...interface{}) error {
return logger.Critical(arg0, args...)
}
@@ -112,26 +113,26 @@ func (fl StdLibLogger) Info(arg0 interface{}, args ...interface{}) {
fl.Log(INFO, arg0, args...)
}
-func (fl StdLibLogger) Warn(arg0 interface{}, args ...interface{}) os.Error {
+func (fl StdLibLogger) Warn(arg0 interface{}, args ...interface{}) error {
return fl.Log(WARNING, arg0, args...)
}
-func (fl StdLibLogger) Error(arg0 interface{}, args ...interface{}) os.Error {
+func (fl StdLibLogger) Error(arg0 interface{}, args ...interface{}) error {
return fl.Log(ERROR, arg0, args...)
}
-func (fl StdLibLogger) Critical(arg0 interface{}, args ...interface{}) os.Error {
+func (fl StdLibLogger) Critical(arg0 interface{}, args ...interface{}) error {
return fl.Log(CRITICAL, arg0, args...)
}
-func (fl StdLibLogger) Log(lvl level, arg0 interface{}, args ...interface{}) (e os.Error) {
+func (fl StdLibLogger) Log(lvl level, arg0 interface{}, args ...interface{}) (e error) {
defer func() {
if x := recover(); x != nil {
var ok bool
- if e, ok = x.(os.Error); ok {
+ if e, ok = x.(error); ok {
return
}
- e = os.NewError("Um... barf")
+ e = errors.New("Um... barf")
}
}()
switch first := arg0.(type) {
View
2 pipeline.go
@@ -2,8 +2,8 @@ package falcore
import (
"container/list"
- "http"
"log"
+ "net/http"
"reflect"
)
View
8 pipeline_test.go
@@ -1,16 +1,16 @@
package falcore
import (
- "testing"
- "container/list"
- "http"
"bytes"
+ "container/list"
+ "net/http"
+ "testing"
"time"
)
func validGetRequest() *Request {
tmp, _ := http.NewRequest("GET", "/hello", bytes.NewBuffer(make([]byte, 0)))
- return newRequest(tmp, nil, time.Nanoseconds())
+ return newRequest(tmp, nil, time.Now())
}
var stageTrack *list.List
View
39 request.go
@@ -1,14 +1,14 @@
package falcore
import (
- "http"
"container/list"
"fmt"
- "time"
- "rand"
"hash"
"hash/crc32"
+ "math/rand"
"net"
+ "net/http"
+ "time"
)
// Request wrapper
@@ -38,26 +38,28 @@ import (
// The Signature is also a cool feature. See the
type Request struct {
ID string
- StartTime int64
- EndTime int64
+ StartTime time.Time
+ EndTime time.Time
HttpRequest *http.Request
Connection net.Conn
PipelineStageStats *list.List
CurrentStage *PipelineStageStat
pipelineHash hash.Hash32
- piplineTot int64
- Overhead int64
+ piplineTot time.Duration
+ Overhead time.Duration
}
// Used internally to create and initialize a new request.
-func newRequest(request *http.Request, conn net.Conn, startTime int64) *Request {
+func newRequest(request *http.Request, conn net.Conn, startTime time.Time) *Request {
fReq := new(Request)
fReq.HttpRequest = request
fReq.StartTime = startTime
fReq.Connection = conn
// create a semi-unique id to track a connection in the logs
- // the last 3 zeros of time.Nanosecods appear to always be zero
- fReq.ID = fmt.Sprintf("%010x", (fReq.StartTime-(fReq.StartTime-(fReq.StartTime%1e12)))+int64(rand.Intn(999)))
+ // ID is the least significant decimal digits of time with some randomization
+ // 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()
fReq.pipelineHash = crc32.NewIEEE()
return fReq
@@ -71,7 +73,7 @@ func (fReq *Request) startPipelineStage(name string) {
// Finishes the CurrentStage.
func (fReq *Request) finishPipelineStage() {
- fReq.CurrentStage.EndTime = time.Nanoseconds()
+ fReq.CurrentStage.EndTime = time.Now()
fReq.finishCommon()
}
@@ -86,8 +88,7 @@ func (fReq *Request) appendPipelineStage(pss *PipelineStageStat) {
func (fReq *Request) finishCommon() {
fReq.pipelineHash.Write([]byte(fReq.CurrentStage.Name))
fReq.pipelineHash.Write([]byte{fReq.CurrentStage.Status})
- fReq.piplineTot += fReq.CurrentStage.EndTime - fReq.CurrentStage.StartTime
-
+ fReq.piplineTot += fReq.CurrentStage.EndTime.Sub(fReq.CurrentStage.StartTime)
}
// The Signature will only be complete in the RequestDoneCallback. At
@@ -107,7 +108,7 @@ func (fReq *Request) Signature() string {
func (fReq *Request) Trace() {
reqTime := TimeDiff(fReq.StartTime, fReq.EndTime)
req := fReq.HttpRequest
- Trace("%s [%s] %s%s Sig=%s Tot=%.4f", fReq.ID, req.Method, req.Host, req.RawURL, fReq.Signature(), reqTime)
+ Trace("%s [%s] %s%s Sig=%s Tot=%.4f", fReq.ID, req.Method, req.Host, req.URL, fReq.Signature(), reqTime)
l := fReq.PipelineStageStats
for e := l.Front(); e != nil; e = e.Next() {
pss, _ := e.Value.(*PipelineStageStat)
@@ -118,8 +119,8 @@ func (fReq *Request) Trace() {
}
func (fReq *Request) finishRequest() {
- fReq.EndTime = time.Nanoseconds()
- fReq.Overhead = (fReq.EndTime - fReq.StartTime) - fReq.piplineTot
+ fReq.EndTime = time.Now()
+ fReq.Overhead = fReq.EndTime.Sub(fReq.StartTime) - fReq.piplineTot
}
// Container for keeping stats per pipeline stage
@@ -139,13 +140,13 @@ func (fReq *Request) finishRequest() {
type PipelineStageStat struct {
Name string
Status byte
- StartTime int64
- EndTime int64
+ StartTime time.Time
+ EndTime time.Time
}
func NewPiplineStage(name string) *PipelineStageStat {
pss := new(PipelineStageStat)
pss.Name = name
- pss.StartTime = time.Nanoseconds()
+ pss.StartTime = time.Now()
return pss
}
View
7 response.go
@@ -1,9 +1,8 @@
package falcore
import (
- "http"
+ "net/http"
"strings"
- "os"
)
func SimpleResponse(req *http.Request, status int, headers http.Header, body string) *http.Response {
@@ -26,10 +25,10 @@ func SimpleResponse(req *http.Request, status int, headers http.Header, body str
type fixedResBody strings.Reader
-func (s *fixedResBody) Close() os.Error {
+func (s *fixedResBody) Close() error {
return nil
}
-func (s *fixedResBody) Read(b []byte) (int, os.Error) {
+func (s *fixedResBody) Read(b []byte) (int, error) {
return (*strings.Reader)(s).Read(b)
}
View
5 router.go
@@ -1,9 +1,8 @@
package falcore
import (
- "regexp"
"container/list"
- "os"
+ "regexp"
)
// Interface for defining routers
@@ -89,7 +88,7 @@ func (r *PathRouter) AddRoute(route Route) {
}
// convenience method for adding RegexpRoutes
-func (r *PathRouter) AddMatch(match string, filter RequestFilter) (err os.Error) {
+func (r *PathRouter) AddMatch(match string, filter RequestFilter) (err error) {
route := &RegexpRoute{Filter: filter}
if route.Match, err = regexp.Compile(match); err == nil {
r.Routes.PushBack(route)
View
4 router_test.go
@@ -1,9 +1,9 @@
package falcore
import (
- "testing"
+ "net/http"
"regexp"
- "http"
+ "testing"
)
type SimpleFilter int
View
45 server.go
@@ -1,18 +1,19 @@
package falcore
import (
- "http"
- "fmt"
- "os"
- "net"
"bufio"
- "time"
- "io"
"crypto/rand"
"crypto/tls"
+ "errors"
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "os"
"strconv"
"sync"
"syscall"
+ "time"
)
type Server struct {
@@ -37,23 +38,23 @@ func NewServer(port int, pipeline *Pipeline) *Server {
return s
}
-func (srv *Server) FdListen(fd int) os.Error {
- var err os.Error
+func (srv *Server) FdListen(fd int) error {
+ var err error
srv.listenerFile = os.NewFile(fd, "")
if srv.listener, err = net.FileListener(srv.listenerFile); err != nil {
return err
}
if l, ok := srv.listener.(*net.TCPListener); ok {
- l.SetTimeout(3e9)
+ l.SetDeadline(time.Now().Add(3e9))
} else {
- return os.NewError("Broken listener isn't TCP")
+ return errors.New("Broken listener isn't TCP")
}
return nil
}
-func (srv *Server) socketListen() os.Error {
+func (srv *Server) socketListen() error {
var la *net.TCPAddr
- var err os.Error
+ var err error
if la, err = net.ResolveTCPAddr("tcp", srv.Addr); err != nil {
return err
}
@@ -66,14 +67,14 @@ func (srv *Server) socketListen() os.Error {
if srv.listenerFile, err = l.File(); err != nil {
return err
}
- if e := syscall.SetNonblock(srv.listenerFile.Fd(), true); e != 0 {
- return os.Errno(e)
+ if e := syscall.SetNonblock(srv.listenerFile.Fd(), true); e != nil {
+ return e
}
- l.SetTimeout(3e9)
+ l.SetDeadline(time.Now().Add(3e9))
return nil
}
-func (srv *Server) ListenAndServe() os.Error {
+func (srv *Server) ListenAndServe() error {
if srv.Addr == "" {
srv.Addr = ":http"
}
@@ -89,17 +90,17 @@ func (srv *Server) SocketFd() int {
return srv.listenerFile.Fd()
}
-func (srv *Server) ListenAndServeTLS(certFile, keyFile string) os.Error {
+func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error {
if srv.Addr == "" {
srv.Addr = ":https"
}
config := &tls.Config{
Rand: rand.Reader,
- Time: time.Seconds,
+ Time: time.Now,
NextProtos: []string{"http/1.1"},
}
- var err os.Error
+ var err error
config.Certificates = make([]tls.Certificate, 1)
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
@@ -132,7 +133,7 @@ func (srv *Server) Port() int {
return 0
}
-func (srv *Server) serve() (e os.Error) {
+func (srv *Server) serve() (e error) {
var accept = true
srv.AcceptReady <- 1
for accept {
@@ -164,7 +165,7 @@ func (srv *Server) serve() (e os.Error) {
}
func (srv *Server) handler(c net.Conn) {
- startTime := time.Nanoseconds()
+ startTime := time.Now()
defer srv.connectionFinished(c)
buf, err := bufio.NewReaderSize(c, 8192)
if err != nil {
@@ -187,7 +188,7 @@ func (srv *Server) handler(c net.Conn) {
pssInit := new(PipelineStageStat)
pssInit.Name = "server.Init"
pssInit.StartTime = startTime
- pssInit.EndTime = time.Nanoseconds()
+ pssInit.EndTime = time.Now()
request.appendPipelineStage(pssInit)
// execute the pipeline
if res = srv.Pipeline.execute(request); res == nil {
View
10 static_file/file_filter.go
@@ -1,11 +1,11 @@
package static_file
import (
- "http"
"falcore"
- "path/filepath"
- "os"
"mime"
+ "net/http"
+ "os"
+ "path/filepath"
"strings"
)
@@ -41,7 +41,7 @@ func (f *Filter) FilterRequest(req *falcore.Request) (res *http.Response) {
var fileSize int64
if stat, err := os.Stat(asset_path); err == nil {
- fileSize = stat.Size
+ fileSize = stat.Size()
} else {
falcore.Debug("Can't stat %v: %v", asset_path, err)
return falcore.SimpleResponse(req.HttpRequest, 404, nil, "File not found\n")
@@ -50,7 +50,7 @@ func (f *Filter) FilterRequest(req *falcore.Request) (res *http.Response) {
// Open File
if file, err := os.Open(asset_path); err == nil {
// Make sure it's an actual file
- if stat, err := file.Stat(); err == nil && stat.IsRegular() {
+ if stat, err := file.Stat(); err == nil && stat.Mode() & os.ModeType == 0 {
res = &http.Response{
Request: req.HttpRequest,
StatusCode: 200,
View
18 static_file/file_filter_test.go
@@ -1,18 +1,18 @@
package static_file
import (
- "testing"
+ "bytes"
"falcore"
- "os"
- "http"
- "strings"
+
"fmt"
- "io/ioutil"
"io"
- "bytes"
- "time"
- "mime"
+ "io/ioutil"
"log"
+ "mime"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
)
var srv *falcore.Server
@@ -47,7 +47,7 @@ func port() int {
return srv.Port()
}
-func get(p string) (r *http.Response, err os.Error) {
+func get(p string) (r *http.Response, err error) {
req, _ := http.NewRequest("GET", fmt.Sprintf("http://%v", fmt.Sprintf("localhost:%v/", port())), nil)
req.URL.Path = p
r, err = http.DefaultTransport.RoundTrip(req)
View
14 string_body.go
@@ -1,11 +1,11 @@
package falcore
import (
- "strings"
- "http"
- "io/ioutil"
- "os"
"io"
+ "io/ioutil"
+ "net/http"
+
+ "strings"
)
// Keeps the body of a request in a string so it can be re-read at each stage of the pipeline
@@ -35,7 +35,7 @@ func (sbf *StringBodyFilter) FilterRequest(request *Request) *http.Response {
// reads the request body and replaces the buffer with self
// returns nil if the body is multipart and not replaced
-func ReadRequestBody(r *http.Request) (sb *StringBody, err os.Error) {
+func ReadRequestBody(r *http.Request) (sb *StringBody, err error) {
ct := r.Header.Get("Content-Type")
// leave it on the buffer if we're multipart
if strings.SplitN(ct, ";", 2)[0] != "multipart/form-data" && r.ContentLength > 0 {
@@ -54,11 +54,11 @@ func ReadRequestBody(r *http.Request) (sb *StringBody, err os.Error) {
return nil, nil // ignore
}
-func (sb *StringBody) Read(b []byte) (n int, err os.Error) {
+func (sb *StringBody) Read(b []byte) (n int, err error) {
return sb.BodyBuffer.Read(b)
}
-func (sb *StringBody) Close() os.Error {
+func (sb *StringBody) Close() error {
// start over
sb.BodyBuffer = strings.NewReader(sb.BodyString)
return nil
View
6 string_body_test.go
@@ -1,18 +1,18 @@
package falcore
import (
+ "bytes"
+ "net/http"
"testing"
- "http"
"time"
- "bytes"
)
func TestStringBody(t *testing.T) {
expected := []byte("HOT HOT HOT!!!")
tmp, _ := http.NewRequest("POST", "/hello", bytes.NewBuffer(expected))
tmp.Header.Set("Content-Type", "text/plain")
tmp.ContentLength = int64(len(expected))
- req := newRequest(tmp, nil, time.Nanoseconds())
+ req := newRequest(tmp, nil, time.Now())
req.startPipelineStage("StringBodyTest")
sbf := &StringBodyFilter{}
View
23 upstream/upstream.go
@@ -1,12 +1,12 @@
package upstream
import (
- "http"
- "os"
- "net"
+ "falcore"
+
"fmt"
+ "net"
+ "net/http"
"time"
- "falcore"
)
type Upstream struct {
@@ -15,7 +15,7 @@ type Upstream struct {
// The port on the upstream host
Port int
// Default 60 seconds
- Timeout int64
+ Timeout time.Duration
// Will ignore https on the incoming request and always upstream http
ForceHttp bool
// Ping URL Path-only for checking upness
@@ -50,12 +50,13 @@ func NewUpstream(host string, port int, forceHttp bool) *Upstream {
u.host = fmt.Sprintf("%v:%v", u.Host, u.Port)
u.transport = new(http.Transport)
- u.transport.Dial = func(n, addr string) (c net.Conn, err os.Error) {
+
+ u.transport.Dial = func(n, addr string) (c net.Conn, err error) {
falcore.Fine("Dialing connection to %v", u.tcpaddr)
var ctcp *net.TCPConn
ctcp, err = net.DialTCP("tcp4", nil, u.tcpaddr)
if ctcp != nil {
- ctcp.SetTimeout(u.Timeout)
+ ctcp.SetDeadline(time.Now().Add(u.Timeout))
}
if err != nil {
falcore.Error("Dial Failed: %v", err)
@@ -72,18 +73,18 @@ func (u *Upstream) SetPoolSize(size int) {
}
func (u *Upstream) FilterRequest(request *falcore.Request) (res *http.Response) {
- var err os.Error
+ var err error
req := request.HttpRequest
// Force the upstream to use http
if u.ForceHttp || req.URL.Scheme == "" {
req.URL.Scheme = "http"
req.URL.Host = req.Host
}
- before := time.Nanoseconds()
+ before := time.Now()
req.Header.Set("Connection", "Keep-Alive")
res, err = u.transport.RoundTrip(req)
- diff := falcore.TimeDiff(before, time.Nanoseconds())
+ diff := falcore.TimeDiff(before, time.Now())
if err != nil {
if nerr, ok := err.(net.Error); ok && nerr.Timeout() {
falcore.Error("%s Upstream Timeout error: %v", request.ID, err)
@@ -95,7 +96,7 @@ func (u *Upstream) FilterRequest(request *falcore.Request) (res *http.Response)
request.CurrentStage.Status = 2 // Fail
}
}
- falcore.Debug("%s [%s] [%s%s] s=%d Time=%.4f", request.ID, req.Method, u.host, req.RawURL, res.StatusCode, diff)
+ falcore.Debug("%s [%s] [%s%s] s=%d Time=%.4f", request.ID, req.Method, u.host, req.URL, res.StatusCode, diff)
return
}
View
10 upstream/upstream_pool.go
@@ -1,13 +1,12 @@
package upstream
import (
- "os"
- "strings"
+ "falcore"
+ "net/http"
"strconv"
+ "strings"
"sync"
"time"
- "falcore"
- "http"
)
type UpstreamEntryConfig struct {
@@ -21,6 +20,7 @@ type UpstreamEntry struct {
Upstream *Upstream
Weight int
}
+
// An UpstreamPool is a list of upstream servers which are considered
// functionally equivalent. The pool will round-robin the requests to the servers.
type UpstreamPool struct {
@@ -52,7 +52,7 @@ func NewUpstreamPool(name string, config []UpstreamEntryConfig) *UpstreamPool {
upstreamHost := parts[0]
upstreamPort := 80
if len(parts) > 1 {
- var err os.Error
+ var err error
upstreamPort, err = strconv.Atoi(parts[1])
if err != nil {
upstreamPort = 80

0 comments on commit 8eb6578

Please sign in to comment.