Skip to content

Commit

Permalink
restructure repo
Browse files Browse the repository at this point in the history
* move router source to toplevel, which is more standard
* move config package into router package
* take vendored dependencies out; this moves to cf-release
* simplify travis.yml accordingly
  • Loading branch information
vito committed Jul 11, 2013
1 parent 2249248 commit 6e0da1c
Show file tree
Hide file tree
Showing 106 changed files with 61 additions and 18,945 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ matrix:

install:
- gem install nats
- export GOPATH=$TRAVIS_BUILD_DIR
- go build ./...

script: bin/test router
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/router/common/component.go → common/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
mbus "github.com/cloudfoundry/go_cfmessagebus"
steno "github.com/cloudfoundry/gosteno"
"net/http"
. "router/common/http"
. "github.com/cloudfoundry/gorouter/common/http"
"runtime"
"time"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/router/config/config.go → config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package config
package router

import (
"io/ioutil"
"launchpad.net/goyaml"
vcap "router/common"
vcap "github.com/cloudfoundry/gorouter/common"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion src/router/config/config_test.go → config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package config
package router

import (
. "launchpad.net/gocheck"
Expand Down
30 changes: 23 additions & 7 deletions src/router/common/spec/config.go → helper_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
package spec
package router

import (
"router/config"
steno "github.com/cloudfoundry/gosteno"
. "launchpad.net/gocheck"
"testing"
"time"
)

func SpecConfig(natsPort, statusPort, proxyPort uint16) *config.Config {
c := config.DefaultConfig()
func Test(t *testing.T) {
config := &steno.Config{
Sinks: []steno.Sink{},
Codec: steno.NewJsonCodec(),
Level: steno.LOG_INFO,
}

steno.Init(config)

log = steno.NewLogger("test")

TestingT(t)
}

func SpecConfig(natsPort, statusPort, proxyPort uint16) *Config {
c := DefaultConfig()
c.Port = proxyPort
c.Index = 2
c.TraceKey = "my_trace_key"
Expand All @@ -20,20 +36,20 @@ func SpecConfig(natsPort, statusPort, proxyPort uint16) *config.Config {
c.DropletStaleThreshold = 0
c.PublishActiveAppsInterval = 0

c.Status = config.StatusConfig{
c.Status = StatusConfig{
Port: statusPort,
User: "user",
Pass: "pass",
}

c.Nats = config.NatsConfig{
c.Nats = NatsConfig{
Host: "localhost",
Port: natsPort,
User: "nats",
Pass: "nats",
}

c.Logging = config.LoggingConfig{
c.Logging = LoggingConfig{
File: "/dev/null",
Level: "info",
}
Expand Down
8 changes: 3 additions & 5 deletions src/router/integration_test.go → integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package router
import (
mbus "github.com/cloudfoundry/go_cfmessagebus"
. "launchpad.net/gocheck"
"router/common/spec"
"router/config"
"router/test"
"github.com/cloudfoundry/gorouter/test"
"time"
)

type IntegrationSuite struct {
Config *config.Config
Config *Config
mbusClient mbus.CFMessageBus
router *Router
}
Expand All @@ -24,7 +22,7 @@ func (s *IntegrationSuite) TestNatsConnectivity(c *C) {
proxyPort := nextAvailPort()
statusPort := nextAvailPort()

s.Config = spec.SpecConfig(natsPort, statusPort, proxyPort)
s.Config = SpecConfig(natsPort, statusPort, proxyPort)
s.Config.PruneStaleDropletsInterval = 5 * time.Second

s.router = NewRouter(s.Config)
Expand Down
5 changes: 2 additions & 3 deletions src/router/logger.go → logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package router
import (
steno "github.com/cloudfoundry/gosteno"
"os"
"router/common"
"router/config"
"github.com/cloudfoundry/gorouter/common"
)

var log *steno.Logger
Expand All @@ -21,7 +20,7 @@ func init() {
log = steno.NewLogger("router.init")
}

func SetupLoggerFromConfig(c *config.Config) {
func SetupLoggerFromConfig(c *Config) {
l, err := steno.GetLogLevel(c.Logging.Level)
if err != nil {
panic(err)
Expand Down
3 changes: 1 addition & 2 deletions src/router/logger_test.go → logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package router
import (
steno "github.com/cloudfoundry/gosteno"
. "launchpad.net/gocheck"
"router/config"
)

type LoggerSuite struct{}

var _ = Suite(&LoggerSuite{})

func (s *LoggerSuite) TestSetupLoggerFromConfig(c *C) {
cfg := config.DefaultConfig()
cfg := DefaultConfig()
cfg.Logging.File = "/tmp/gorouter.log"

SetupLoggerFromConfig(cfg)
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions src/router/perf_test.go → perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package router

import (
"code.google.com/p/gomock/gomock"
"router/config"
"router/test"
"github.com/cloudfoundry/gorouter/test"
"strconv"
"testing"
)
Expand All @@ -14,7 +13,7 @@ const (
)

func BenchmarkRegister(b *testing.B) {
c := config.DefaultConfig()
c := DefaultConfig()
mocksController := gomock.NewController(b)
r := NewRegistry(c, test.NewMockCFMessageBus(mocksController))
p := NewProxy(c, r, NewVarz(r))
Expand Down
5 changes: 2 additions & 3 deletions src/router/proxy.go → proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net"
"net/http"
"os"
"router/config"
"strings"
"sync"
"time"
Expand All @@ -26,7 +25,7 @@ const (
type Proxy struct {
sync.RWMutex
*steno.Logger
*config.Config
*Config
*Registry
Varz
*AccessLogger
Expand Down Expand Up @@ -65,7 +64,7 @@ func (rw *responseWriter) CopyFrom(src io.Reader) (int64, error) {
return io.Copy(dst, src)
}

func NewProxy(c *config.Config, r *Registry, v Varz) *Proxy {
func NewProxy(c *Config, r *Registry, v Varz) *Proxy {
p := &Proxy{
Config: c,
Logger: steno.NewLogger("router.proxy"),
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions src/router/proxy_test.go → proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
. "launchpad.net/gocheck"
"net"
"net/http"
"router/config"
"router/test"
"github.com/cloudfoundry/gorouter/test"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -132,7 +131,7 @@ type ProxySuite struct {
var _ = Suite(&ProxySuite{})

func (s *ProxySuite) SetUpTest(c *C) {
x := config.DefaultConfig()
x := DefaultConfig()
x.TraceKey = "my_trace_key"

mocksController := gomock.NewController(c)
Expand Down
7 changes: 3 additions & 4 deletions src/router/registry.go → registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
mbus "github.com/cloudfoundry/go_cfmessagebus"
steno "github.com/cloudfoundry/gosteno"
"math/rand"
"router/config"
"router/stats"
"router/util"
"github.com/cloudfoundry/gorouter/stats"
"github.com/cloudfoundry/gorouter/util"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -182,7 +181,7 @@ type Registry struct {
messageBus mbus.CFMessageBus
}

func NewRegistry(c *config.Config, messageBusClient mbus.CFMessageBus) *Registry {
func NewRegistry(c *Config, messageBusClient mbus.CFMessageBus) *Registry {
r := &Registry{
messageBus: messageBusClient,
}
Expand Down
7 changes: 3 additions & 4 deletions src/router/registry_test.go → registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"code.google.com/p/gomock/gomock"
"encoding/json"
. "launchpad.net/gocheck"
"router/config"
"router/test"
"github.com/cloudfoundry/gorouter/test"
"time"
)

Expand Down Expand Up @@ -51,9 +50,9 @@ var bar2Reg = &registryMessage{
}

func (s *RegistrySuite) SetUpTest(c *C) {
var configObj *config.Config
var configObj *Config

configObj = config.DefaultConfig()
configObj = DefaultConfig()
configObj.DropletStaleThreshold = 1

s.mocksController = gomock.NewController(c)
Expand Down
11 changes: 5 additions & 6 deletions src/router/router.go → router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ import (
mbus "github.com/cloudfoundry/go_cfmessagebus"
steno "github.com/cloudfoundry/gosteno"
"net"
vcap "router/common"
"router/config"
"router/proxy"
"router/util"
vcap "github.com/cloudfoundry/gorouter/common"
"github.com/cloudfoundry/gorouter/proxy"
"github.com/cloudfoundry/gorouter/util"
"runtime"
"time"
)

type Router struct {
config *config.Config
config *Config
proxy *Proxy
mbusClient mbus.CFMessageBus
registry *Registry
varz Varz
component *vcap.VcapComponent
}

func NewRouter(c *config.Config) *Router {
func NewRouter(c *Config) *Router {
router := &Router{
config: c,
}
Expand Down
7 changes: 3 additions & 4 deletions src/router/router/main.go → router/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package main

import (
"flag"
"router"
"router/config"
"github.com/cloudfoundry/gorouter"
)

var configFile string
Expand All @@ -15,9 +14,9 @@ func init() {
}

func main() {
c := config.DefaultConfig()
c := router.DefaultConfig()
if configFile != "" {
c = config.InitConfigFromFile(configFile)
c = router.InitConfigFromFile(configFile)
}

router.SetupLoggerFromConfig(c)
Expand Down
10 changes: 4 additions & 6 deletions src/router/router_test.go → router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ import (
"net/http"
"os/exec"
"regexp"
"router/common"
"router/common/spec"
"router/config"
"router/test"
"github.com/cloudfoundry/gorouter/common"
"github.com/cloudfoundry/gorouter/test"
"strings"
"time"
)

type RouterSuite struct {
Config *config.Config
Config *Config
natsServerCmd *exec.Cmd
mbusClient mbus.CFMessageBus
router *Router
Expand All @@ -38,7 +36,7 @@ func (s *RouterSuite) SetUpSuite(c *C) {
proxyPort := nextAvailPort()
statusPort := nextAvailPort()

s.Config = spec.SpecConfig(s.natsPort, statusPort, proxyPort)
s.Config = SpecConfig(s.natsPort, statusPort, proxyPort)

s.router = NewRouter(s.Config)
go s.router.Run()
Expand Down
1 change: 0 additions & 1 deletion src/code.google.com/p/gomock
Submodule gomock deleted from 3980f0
1 change: 0 additions & 1 deletion src/github.com/cloudfoundry/go_cfmessagebus
Submodule go_cfmessagebus deleted from 37818a
1 change: 0 additions & 1 deletion src/github.com/cloudfoundry/gosteno
Submodule gosteno deleted from 955a66
1 change: 0 additions & 1 deletion src/github.com/cloudfoundry/yagnats
Submodule yagnats deleted from 79f6d7
1 change: 0 additions & 1 deletion src/github.com/rcrowley/go-metrics
Submodule go-metrics deleted from 84b079
29 changes: 0 additions & 29 deletions src/launchpad.net/gocheck/LICENSE

This file was deleted.

Loading

0 comments on commit 6e0da1c

Please sign in to comment.