Skip to content

Commit

Permalink
Retry on failed connects
Browse files Browse the repository at this point in the history
- Fix all go vet issues

[#69786534]

Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
fraenkel authored and sykesm committed May 27, 2014
1 parent 5f91639 commit 6fcbce2
Show file tree
Hide file tree
Showing 25 changed files with 1,092 additions and 601 deletions.
6 changes: 3 additions & 3 deletions access_log/access_log_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type AccessLogRecord struct {
Request *http.Request
Response *http.Response
StatusCode int
RouteEndpoint *route.Endpoint
StartedAt time.Time
FirstByteAt time.Time
Expand Down Expand Up @@ -42,10 +42,10 @@ func (r *AccessLogRecord) makeRecord() *bytes.Buffer {
fmt.Fprintf(b, `[%s] `, r.FormatStartedAt())
fmt.Fprintf(b, `"%s %s %s" `, r.Request.Method, r.Request.URL.RequestURI(), r.Request.Proto)

if r.Response == nil {
if r.StatusCode == 0 {
fmt.Fprintf(b, "MissingResponseStatusCode ")
} else {
fmt.Fprintf(b, `%d `, r.Response.StatusCode)
fmt.Fprintf(b, `%d `, r.StatusCode)
}

fmt.Fprintf(b, `%d `, r.BodyBytesSent)
Expand Down
4 changes: 1 addition & 3 deletions access_log/access_log_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ func CompleteAccessLogRecord() AccessLogRecord {
RemoteAddr: "FakeRemoteAddr",
},
BodyBytesSent: 23,
Response: &http.Response{
StatusCode: 200,
},
StatusCode: 200,
RouteEndpoint: &route.Endpoint{
ApplicationId: "FakeApplicationId",
},
Expand Down
14 changes: 3 additions & 11 deletions access_log/file_and_loggregator_access_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ var _ = Describe("AccessLog", func() {
testEmitter := NewMockEmitter()
accessLogger := NewFileAndLoggregatorAccessLogger(nil, testEmitter)

routeEndpoint := &route.Endpoint{
ApplicationId: "",
Host: "127.0.0.1",
Port: 4567,
}
routeEndpoint := route.NewEndpoint("", "127.0.0.1", 4567, "", nil)

accessLogRecord := CreateAccessLogRecord()
accessLogRecord.RouteEndpoint = routeEndpoint
Expand Down Expand Up @@ -165,15 +161,11 @@ func CreateAccessLogRecord() *AccessLogRecord {
StatusCode: http.StatusOK,
}

b := &route.Endpoint{
ApplicationId: "my_awesome_id",
Host: "127.0.0.1",
Port: 4567,
}
b := route.NewEndpoint("my_awesome_id", "127.0.0.1", 4567, "", nil)

r := AccessLogRecord{
Request: req,
Response: res,
StatusCode: res.StatusCode,
RouteEndpoint: b,
StartedAt: time.Unix(10, 100000000),
FirstByteAt: time.Unix(10, 200000000),
Expand Down
8 changes: 4 additions & 4 deletions common/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"encoding/json"
"errors"
"fmt"
. "github.com/cloudfoundry/gorouter/common/http"
steno "github.com/cloudfoundry/gosteno"
"github.com/cloudfoundry/yagnats"
"net"
"net/http"
"runtime"
"time"
. "github.com/cloudfoundry/gorouter/common/http"
steno "github.com/cloudfoundry/gosteno"
"github.com/cloudfoundry/yagnats"
)

var procStat *ProcessStatus
Expand Down Expand Up @@ -81,7 +81,7 @@ func (c *VcapComponent) Start() error {
return err
}

c.Host = fmt.Sprintf("%s:%s", host, port)
c.Host = fmt.Sprintf("%s:%d", host, port)
}

if c.Credentials == nil || len(c.Credentials) != 2 {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
logger.Fatalf("Error connecting to NATS: %s\n", err)
}

registry := rregistry.NewCFRegistry(c, natsClient)
registry := rregistry.NewRouteRegistry(c, natsClient)

varz := rvarz.NewVarz(registry)

Expand Down
2 changes: 2 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var _ = Describe("Router Integration", func() {

It("waits for all requests to finish", func() {
mbusClient, err := newMessageBus(config)
Ω(err).ShouldNot(HaveOccurred())

blocker := make(chan bool)
longApp := test.NewTestApp([]route.Uri{"longapp.vcap.me"}, proxyPort, mbusClient, nil)
Expand Down Expand Up @@ -148,6 +149,7 @@ var _ = Describe("Router Integration", func() {

It("will timeout if requests take too long", func() {
mbusClient, err := newMessageBus(config)
Ω(err).ShouldNot(HaveOccurred())

blocker := make(chan bool)
resultCh := make(chan error, 1)
Expand Down
7 changes: 2 additions & 5 deletions perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ = Describe("AccessLogRecord", func() {
Measure("Register", func(b Benchmarker) {
c := config.DefaultConfig()
mbus := fakeyagnats.New()
r := registry.NewCFRegistry(c, mbus)
r := registry.NewRouteRegistry(c, mbus)

accesslog, err := access_log.CreateRunningAccessLogger(c)
Ω(err).ToNot(HaveOccurred())
Expand All @@ -38,10 +38,7 @@ var _ = Describe("AccessLogRecord", func() {
str := strconv.Itoa(i)
r.Register(
route.Uri("bench.vcap.me."+str),
&route.Endpoint{
Host: "localhost",
Port: uint16(i),
},
route.NewEndpoint("", "localhost", uint16(i), "", nil),
)
}
})
Expand Down
Loading

0 comments on commit 6fcbce2

Please sign in to comment.