示例#1
0
func newClient(url string) *client {
	return &client{
		httpClient:          cfhttp.NewClient(),
		streamingHTTPClient: cfhttp.NewStreamingClient(),
		reqGen:              rata.NewRequestGenerator(url, Routes),
	}
}
示例#2
0
								select {
								case <-serveFiveHundreds:
									w.WriteHeader(http.StatusInternalServerError)
								default:
									proxy.ServeHTTP(w, r)
								}
							}),
						)

						fakeConsulURL, err := url.Parse(fakeConsul.URL)
						Expect(err).NotTo(HaveOccurred())

						client, err := api.NewClient(&api.Config{
							Address:    fakeConsulURL.Host,
							Scheme:     fakeConsulURL.Scheme,
							HttpClient: cfhttp.NewStreamingClient(),
						})
						Expect(err).NotTo(HaveOccurred())

						consulClient = consuladapter.NewConsulClient(client)
						presenceTTL = 6 * time.Second
					})

					Context("for longer than the MonitorRetries * MonitorRetryTime", func() {
						It("drops its presence", func() {
							// Serve 500's to simulate a leader election. We know that we need
							// to serve more than lockTTL / 2 500's to lose the lock.
							for i := 0; i < 4; i++ {
								Eventually(serveFiveHundreds).Should(BeSent(struct{}{}))
							}
							// Close the existing connection with consul so that the