func buildProxy(c *config.Config, registry rregistry.RegistryInterface, accessLogger access_log.AccessLogger, reporter metrics.ProxyReporter, crypto secure.Crypto, cryptoPrev secure.Crypto) proxy.Proxy { args := proxy.ProxyArgs{ EndpointTimeout: c.EndpointTimeout, Ip: c.Ip, TraceKey: c.TraceKey, Registry: registry, Reporter: reporter, AccessLogger: accessLogger, SecureCookies: c.SecureCookies, TLSConfig: &tls.Config{ CipherSuites: c.CipherSuites, InsecureSkipVerify: c.SSLSkipValidation, }, RouteServiceEnabled: c.RouteServiceEnabled, RouteServiceTimeout: c.RouteServiceTimeout, Crypto: crypto, CryptoPrev: cryptoPrev, ExtraHeadersToLog: c.ExtraHeadersToLog, FakeDomain: c.Domain, } return proxy.NewProxy(args) }
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, }) r.Register(route.Uri("some-app"), &route.Endpoint{}) }) Context("Log response time", func() { It("logs response time for HTTP connections", func() { body := []byte("some body") req := test_util.NewRequest("GET", "some-app", "/", bytes.NewReader(body)) resp := httptest.NewRecorder()
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() }) AfterEach(func() { if natsRunner != nil { natsRunner.Stop() } if router != nil {
"vulcan/router/metrics/fakes" ) var _ = Describe("AccessLogRecord", func() { Measure("Register", func(b Benchmarker) { c := config.DefaultConfig() mbus := fakeyagnats.Connect() r := registry.NewRouteRegistry(c, mbus, new(fakes.FakeRouteReporter)) accesslog, err := access_log.CreateRunningAccessLogger(c) Expect(err).ToNot(HaveOccurred()) proxy.NewProxy(proxy.ProxyArgs{ EndpointTimeout: c.EndpointTimeout, Ip: c.Ip, TraceKey: c.TraceKey, Registry: r, Reporter: varz.NewVarz(r), AccessLogger: accesslog, }) b.Time("RegisterTime", func() { for i := 0; i < 1000; i++ { str := strconv.Itoa(i) r.Register( route.Uri("bench.vcap.me."+str), route.NewEndpoint("", "localhost", uint16(i), "", nil, -1, ""), ) } }) }, 10)