fakeAccessLogger *fakelogger.FakeAccessLogger r *registry.RouteRegistry ) Context("ServeHTTP", func() { BeforeEach(func() { tlsConfig := &tls.Config{ CipherSuites: conf.CipherSuites, InsecureSkipVerify: conf.SSLSkipValidation, } fakeAccessLogger = &fakelogger.FakeAccessLogger{} mbus := fakeyagnats.Connect() r = registry.NewRouteRegistry(conf, mbus, new(fakes.FakeRouteReporter)) proxyObj = proxy.NewProxy(proxy.ProxyArgs{ EndpointTimeout: conf.EndpointTimeout, Ip: conf.Ip, TraceKey: conf.TraceKey, Registry: r, Reporter: nullVarz{}, AccessLogger: fakeAccessLogger, SecureCookies: conf.SecureCookies, TLSConfig: tlsConfig, RouteServiceEnabled: conf.RouteServiceEnabled, RouteServiceTimeout: conf.RouteServiceTimeout, Crypto: crypto, CryptoPrev: cryptoPrev, })
func main() { c := config.DefaultConfig() logCounter := vcap.NewLogCounter() if configFile != "" { c = config.InitConfigFromFile(configFile) } InitLoggerFromConfig(c, logCounter) logger := steno.NewLogger("router.main") err := dropsonde.Initialize(c.Logging.MetronAddress, c.Logging.JobName) if err != nil { logger.Errorf("Dropsonde failed to initialize: %s", err.Error()) os.Exit(1) } // setup number of procs if c.GoMaxProcs != 0 { runtime.GOMAXPROCS(c.GoMaxProcs) } if c.DebugAddr != "" { cf_debug_server.Run(c.DebugAddr) } logger.Info("Setting up etcd connection") etcdEndpoint, err := endpoint.NewEtcdEndpoint(c) if err != nil { os.Exit(1) } metricsReporter := metrics.NewMetricsReporter() registry := rregistry.NewRouteRegistry(c, etcdEndpoint, metricsReporter) logger.Info("Setting up routing_api route fetcher") setupRouteFetcher(c, registry) varz := rvarz.NewVarz(registry) compositeReporter := metrics.NewCompositeReporter(varz, metricsReporter) accessLogger, err := access_log.CreateRunningAccessLogger(c) if err != nil { logger.Fatalf("Error creating access logger: %s\n", err) } var crypto secure.Crypto var cryptoPrev secure.Crypto if c.RouteServiceEnabled { crypto = createCrypto(c.RouteServiceSecret, logger) if c.RouteServiceSecretPrev != "" { cryptoPrev = createCrypto(c.RouteServiceSecretPrev, logger) } } proxy := buildProxy(c, registry, accessLogger, compositeReporter, crypto, cryptoPrev) router, err := router.NewRouter(c, proxy, etcdEndpoint, registry, varz, logCounter) if err != nil { logger.Errorf("An error occurred: %s", err.Error()) os.Exit(1) } errChan := router.Run() logger.Info("gorouter.started") waitOnErrOrSignal(c, logger, errChan, router) os.Exit(0) }
"vulcan/router/registry" "vulcan/router/route" . "vulcan/router/varz" "encoding/json" "fmt" "net/http" "time" ) var _ = Describe("Varz", func() { var Varz Varz var Registry *registry.RouteRegistry BeforeEach(func() { Registry = registry.NewRouteRegistry(config.DefaultConfig(), fakeyagnats.Connect(), new(fakes.FakeRouteReporter)) Varz = NewVarz(Registry) }) It("contains the following items", func() { v := Varz members := []string{ "responses_2xx", "responses_3xx", "responses_4xx", "responses_5xx", "responses_xxx", "latency", "rate", "tags",
var router *Router var natsPort uint16 BeforeEach(func() { natsPort = test_util.NextAvailPort() natsRunner = natsrunner.NewNATSRunner(int(natsPort)) natsRunner.Start() proxyPort := test_util.NextAvailPort() statusPort := test_util.NextAvailPort() config = test_util.SpecConfig(natsPort, statusPort, proxyPort) config.EndpointTimeout = 5 * time.Second mbusClient = natsRunner.MessageBus registry = rregistry.NewRouteRegistry(config, mbusClient, new(fakes.FakeRouteReporter)) varz = vvarz.NewVarz(registry) logcounter := vcap.NewLogCounter() proxy := proxy.NewProxy(proxy.ProxyArgs{ EndpointTimeout: config.EndpointTimeout, Ip: config.Ip, TraceKey: config.TraceKey, Registry: registry, Reporter: varz, AccessLogger: &access_log.NullAccessLogger{}, }) r, err := NewRouter(config, proxy, mbusClient, registry, varz, logcounter) Expect(err).ToNot(HaveOccurred()) router = r r.Run() })