• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang forward.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/mailgun/oxy/forward.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestRequestLimitReached

func (s *STSuite) TestRequestLimitReached(c *C) {
	srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
		w.Write([]byte("hello"))
	})
	defer srv.Close()

	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	// this is our redirect to server
	rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		req.URL = testutils.ParseURI(srv.URL)
		fwd.ServeHTTP(w, req)
	})

	// stream handler will forward requests to redirect
	st, err := New(rdr, Logger(utils.NewFileLogger(os.Stdout, utils.INFO)), MaxRequestBodyBytes(4))
	c.Assert(err, IsNil)

	proxy := httptest.NewServer(st)
	defer proxy.Close()

	re, _, err := testutils.Get(proxy.URL, testutils.Body("this request is too long"))
	c.Assert(err, IsNil)
	c.Assert(re.StatusCode, Equals, http.StatusRequestEntityTooLarge)
}
开发者ID:Christeefym,项目名称:lantern,代码行数:27,代码来源:stream_test.go


示例2: syncApps

func syncApps(jsontasks *MarathonTasks, jsonapps *MarathonApps) {
	apps = Apps{Apps: make(map[string]App)}
	apps.Lock()
	defer apps.Unlock()
	for _, task := range jsontasks.Tasks {
		// Use regex to remove characters that are not allowed in hostnames
		re := regexp.MustCompile("[^0-9a-z-]")
		appid := re.ReplaceAllLiteralString(task.AppId, "")
		for _, v := range jsonapps.Apps {
			if v.Id == task.AppId {
				if s, ok := v.Labels["moxy_subdomain"]; ok {
					appid = s
				}
			}
		}
		if len(task.HealthCheckResults) == 1 {
			if task.HealthCheckResults[0].Alive == false {
				continue
			}
		}
		if s, ok := apps.Apps[appid]; ok {
			s.Lb.UpsertServer(testutils.ParseURI("http://" + task.Host + ":" + strconv.FormatInt(task.Ports[0], 10)))
			s.Tasks = append(s.Tasks, task.Host+":"+strconv.FormatInt(task.Ports[0], 10))
			apps.Apps[appid] = s
		} else {
			var s = App{}
			s.Fwd, _ = forward.New(forward.PassHostHeader(true))
			s.Lb, _ = roundrobin.New(s.Fwd)
			s.Lb.UpsertServer(testutils.ParseURI("http://" + task.Host + ":" + strconv.FormatInt(task.Ports[0], 10)))
			s.Tasks = []string{task.Host + ":" + strconv.FormatInt(task.Ports[0], 10)}
			apps.Apps[appid] = s
		}
	}
}
开发者ID:scalp42,项目名称:moxy,代码行数:34,代码来源:marathon.go


示例3: TestUpsertWeight

func (s *RRSuite) TestUpsertWeight(c *C) {
	a := testutils.NewResponder("a")
	defer a.Close()

	b := testutils.NewResponder("b")
	defer b.Close()

	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	c.Assert(lb.UpsertServer(testutils.ParseURI(a.URL)), IsNil)
	c.Assert(lb.UpsertServer(testutils.ParseURI(b.URL)), IsNil)

	proxy := httptest.NewServer(lb)
	defer proxy.Close()

	c.Assert(seq(c, proxy.URL, 3), DeepEquals, []string{"a", "b", "a"})

	c.Assert(lb.UpsertServer(testutils.ParseURI(b.URL), Weight(3)), IsNil)

	c.Assert(seq(c, proxy.URL, 4), DeepEquals, []string{"b", "b", "a", "b"})
}
开发者ID:2722,项目名称:lantern,代码行数:25,代码来源:rr_test.go


示例4: TestNoBody

func (s *STSuite) TestNoBody(c *C) {
	srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
		w.WriteHeader(http.StatusOK)
	})
	defer srv.Close()

	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	// this is our redirect to server
	rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		req.URL = testutils.ParseURI(srv.URL)
		fwd.ServeHTTP(w, req)
	})

	// stream handler will forward requests to redirect
	st, err := New(rdr, Logger(utils.NewFileLogger(os.Stdout, utils.INFO)))
	c.Assert(err, IsNil)

	proxy := httptest.NewServer(st)
	defer proxy.Close()

	re, _, err := testutils.Get(proxy.URL)
	c.Assert(err, IsNil)
	c.Assert(re.StatusCode, Equals, http.StatusOK)
}
开发者ID:Christeefym,项目名称:lantern,代码行数:27,代码来源:stream_test.go


示例5: TestCustomErrorHandler

func (s *STSuite) TestCustomErrorHandler(c *C) {
	srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
		w.Write([]byte("hello, this response is too large"))
	})
	defer srv.Close()

	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	// this is our redirect to server
	rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		req.URL = testutils.ParseURI(srv.URL)
		fwd.ServeHTTP(w, req)
	})

	// stream handler will forward requests to redirect
	errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, req *http.Request, err error) {
		w.WriteHeader(http.StatusTeapot)
		w.Write([]byte(http.StatusText(http.StatusTeapot)))
	})
	st, err := New(rdr, Logger(utils.NewFileLogger(os.Stdout, utils.INFO)), MaxResponseBodyBytes(4), ErrorHandler(errHandler))
	c.Assert(err, IsNil)

	proxy := httptest.NewServer(st)
	defer proxy.Close()

	re, _, err := testutils.Get(proxy.URL)
	c.Assert(err, IsNil)
	c.Assert(re.StatusCode, Equals, http.StatusTeapot)
}
开发者ID:Christeefym,项目名称:lantern,代码行数:31,代码来源:stream_test.go


示例6: TestChunkedEncodingLimitReached

func (s *STSuite) TestChunkedEncodingLimitReached(c *C) {
	srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
		w.Write([]byte("hello"))
	})
	defer srv.Close()

	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	// this is our redirect to server
	rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		req.URL = testutils.ParseURI(srv.URL)
		fwd.ServeHTTP(w, req)
	})

	// stream handler will forward requests to redirect
	st, err := New(rdr, Logger(utils.NewFileLogger(os.Stdout, utils.INFO)), MemRequestBodyBytes(4), MaxRequestBodyBytes(8))
	c.Assert(err, IsNil)

	proxy := httptest.NewServer(st)
	defer proxy.Close()

	conn, err := net.Dial("tcp", testutils.ParseURI(proxy.URL).Host)
	c.Assert(err, IsNil)
	fmt.Fprintf(conn, "POST / HTTP/1.0\r\nTransfer-Encoding: chunked\r\n\r\n4\r\ntest\r\n5\r\ntest1\r\n5\r\ntest2\r\n0\r\n\r\n")
	status, err := bufio.NewReader(conn).ReadString('\n')

	c.Assert(status, Equals, "HTTP/1.0 413 Request Entity Too Large\r\n")
}
开发者ID:Christeefym,项目名称:lantern,代码行数:30,代码来源:stream_test.go


示例7: TestPreservesTLS

// Make sure that stream handler preserves TLS settings
func (s *STSuite) TestPreservesTLS(c *C) {
	srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
		w.WriteHeader(http.StatusOK)
		w.Write([]byte("ok"))
	})
	defer srv.Close()

	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	var t *tls.ConnectionState
	// this is our redirect to server
	rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		t = req.TLS
		req.URL = testutils.ParseURI(srv.URL)
		fwd.ServeHTTP(w, req)
	})

	// stream handler will forward requests to redirect
	st, err := New(rdr, Logger(utils.NewFileLogger(os.Stdout, utils.INFO)))
	c.Assert(err, IsNil)

	proxy := httptest.NewUnstartedServer(st)
	proxy.StartTLS()
	defer proxy.Close()

	re, _, err := testutils.Get(proxy.URL)
	c.Assert(err, IsNil)
	c.Assert(re.StatusCode, Equals, http.StatusOK)

	c.Assert(t, NotNil)
}
开发者ID:Christeefym,项目名称:lantern,代码行数:34,代码来源:stream_test.go


示例8: TestRebalancerLive

func (s *RBSuite) TestRebalancerLive(c *C) {
	a, b := testutils.NewResponder("a"), testutils.NewResponder("b")
	defer a.Close()
	defer b.Close()

	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	rb, err := NewRebalancer(lb, RebalancerBackoff(time.Millisecond), RebalancerClock(s.clock))
	c.Assert(err, IsNil)

	rb.UpsertServer(testutils.ParseURI(a.URL))
	rb.UpsertServer(testutils.ParseURI(b.URL))
	rb.UpsertServer(testutils.ParseURI("http://localhost:62345"))

	proxy := httptest.NewServer(rb)
	defer proxy.Close()

	for i := 0; i < 1000; i += 1 {
		testutils.Get(proxy.URL)
		if i%10 == 0 {
			s.clock.CurrentTime = s.clock.CurrentTime.Add(rb.backoffDuration + time.Second)
		}
	}

	// load balancer changed weights
	c.Assert(rb.servers[0].curWeight, Equals, FSMMaxWeight)
	c.Assert(rb.servers[1].curWeight, Equals, FSMMaxWeight)
	c.Assert(rb.servers[2].curWeight, Equals, 1)
}
开发者ID:2722,项目名称:lantern,代码行数:33,代码来源:rebalancer_test.go


示例9: watchWebRequests

func (ff *ForwardFrontend) watchWebRequests() {
	fwd, _ := forward.New()

	proxy := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		hostname := strings.Split(req.Host, ".")[0]

		for _, event := range ff.routes {
			if event.Hostname == hostname {
				req.URL = testutils.ParseURI(fmt.Sprintf("http://%v:%v", event.Endpoint, event.Port))
				fwd.ServeHTTP(w, req)
				log.Printf("%v:%v:Serving request. Hostname: %v Target: %v Port: %v\n", ff.config.Hostname, ff.config.Port, hostname, event.Endpoint, event.Port)
			}
		}
	})

	s := &http.Server{
		Addr:    fmt.Sprintf(":%v", ff.config.Port),
		Handler: ff.basicAuth(proxy),
	}

	if ff.config.SSL {
		if ff.config.CA != "" {
			s.TLSConfig = ff.getCACert()
		}

		log.Printf("Listening on port: %v TLS: %v\n", ff.config.Port, ff.config.SSL)
		s.ListenAndServeTLS(ff.config.Cert, ff.config.Key)
	} else {
		log.Printf("Listening on port: %v TLS: %v\n", ff.config.Port, ff.config.SSL)
		s.ListenAndServe()
	}

}
开发者ID:rpheuts,项目名称:routery,代码行数:33,代码来源:forwardfrontend.go


示例10: TestRebalancerRemoveServer

func (s *RBSuite) TestRebalancerRemoveServer(c *C) {
	a, b := testutils.NewResponder("a"), testutils.NewResponder("b")
	defer a.Close()
	defer b.Close()

	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	rb, err := NewRebalancer(lb)
	c.Assert(err, IsNil)

	rb.UpsertServer(testutils.ParseURI(a.URL))
	rb.UpsertServer(testutils.ParseURI(b.URL))

	proxy := httptest.NewServer(rb)
	defer proxy.Close()

	c.Assert(seq(c, proxy.URL, 3), DeepEquals, []string{"a", "b", "a"})

	c.Assert(rb.RemoveServer(testutils.ParseURI(a.URL)), IsNil)
	c.Assert(seq(c, proxy.URL, 3), DeepEquals, []string{"b", "b", "b"})
}
开发者ID:2722,项目名称:lantern,代码行数:25,代码来源:rebalancer_test.go


示例11: TestWeighted

func (s *RRSuite) TestWeighted(c *C) {
	a := testutils.NewResponder("a")
	defer a.Close()

	b := testutils.NewResponder("b")
	defer b.Close()

	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	lb.UpsertServer(testutils.ParseURI(a.URL), Weight(3))
	lb.UpsertServer(testutils.ParseURI(b.URL), Weight(2))

	proxy := httptest.NewServer(lb)
	defer proxy.Close()

	c.Assert(seq(c, proxy.URL, 6), DeepEquals, []string{"a", "a", "b", "a", "b", "a"})

	w, ok := lb.ServerWeight(testutils.ParseURI(a.URL))
	c.Assert(w, Equals, 3)
	c.Assert(ok, Equals, true)

	w, ok = lb.ServerWeight(testutils.ParseURI(b.URL))
	c.Assert(w, Equals, 2)
	c.Assert(ok, Equals, true)

	w, ok = lb.ServerWeight(testutils.ParseURI("http://caramba:4000"))
	c.Assert(w, Equals, -1)
	c.Assert(ok, Equals, false)
}
开发者ID:2722,项目名称:lantern,代码行数:33,代码来源:rr_test.go


示例12: TestFileStreamingResponse

func (s *STSuite) TestFileStreamingResponse(c *C) {
	srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
		w.Write([]byte("hello, this response is too large to fit in memory"))
	})
	defer srv.Close()

	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	// this is our redirect to server
	rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		req.URL = testutils.ParseURI(srv.URL)
		fwd.ServeHTTP(w, req)
	})

	// stream handler will forward requests to redirect
	st, err := New(rdr, Logger(utils.NewFileLogger(os.Stdout, utils.INFO)), MemResponseBodyBytes(4))
	c.Assert(err, IsNil)

	proxy := httptest.NewServer(st)
	defer proxy.Close()

	re, body, err := testutils.Get(proxy.URL)
	c.Assert(err, IsNil)
	c.Assert(re.StatusCode, Equals, http.StatusOK)
	c.Assert(string(body), Equals, "hello, this response is too large to fit in memory")
}
开发者ID:Christeefym,项目名称:lantern,代码行数:28,代码来源:stream_test.go


示例13: New

func New() (*HTTPConnectForwarder, error) {
	fwd, err := forward.New()
	if err != nil {
		return nil, err
	}
	return &HTTPConnectForwarder{
		fwd: fwd,
	}, nil
}
开发者ID:Nuos,项目名称:chained-server,代码行数:9,代码来源:connectforward.go


示例14: NewUpdater

func NewUpdater(master string) (updater *Updater) {
	fwd, err := forward.New()
	lb, err := roundrobin.New(fwd)
	masterUrl, err := url.Parse(master)
	lb.UpsertServer(masterUrl)

	if err != nil {
		panic(err)
	}

	return &Updater{lb: lb, master: master}
}
开发者ID:gitter-badger,项目名称:go-solr-proxy,代码行数:12,代码来源:updater.go


示例15: NewProxy

func NewProxy(hosts map[string]string) (*Proxy, error) {
	clog := log.WithFields(log.Fields{})
	fwd, err := forward.New(forward.Logger(clog))
	if err != nil {
		return nil, err
	}
	return &Proxy{
		hosts: hosts,
		fwd:   fwd,
		log:   clog,
	}, nil
}
开发者ID:ericflo,项目名称:kube-http-proxy,代码行数:12,代码来源:main.go


示例16: TestRebalancerCascading

// Test scenario when increaing the weight on good endpoints made it worse
func (s *RBSuite) TestRebalancerCascading(c *C) {
	a, b, d := testutils.NewResponder("a"), testutils.NewResponder("b"), testutils.NewResponder("d")
	defer a.Close()
	defer b.Close()
	defer d.Close()

	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	newMeter := func() (Meter, error) {
		return &testMeter{}, nil
	}
	rb, err := NewRebalancer(lb, RebalancerMeter(newMeter), RebalancerClock(s.clock), RebalancerLogger(s.log))
	c.Assert(err, IsNil)

	rb.UpsertServer(testutils.ParseURI(a.URL))
	rb.UpsertServer(testutils.ParseURI(b.URL))
	rb.UpsertServer(testutils.ParseURI(d.URL))
	rb.servers[0].meter.(*testMeter).rating = 0.3

	proxy := httptest.NewServer(rb)
	defer proxy.Close()

	for i := 0; i < 6; i += 1 {
		testutils.Get(proxy.URL)
		testutils.Get(proxy.URL)
		s.clock.CurrentTime = s.clock.CurrentTime.Add(rb.backoffDuration + time.Second)
	}

	// We have increased the load, and the situation became worse as the other servers started failing
	c.Assert(rb.servers[0].curWeight, Equals, 1)
	c.Assert(rb.servers[1].curWeight, Equals, FSMMaxWeight)
	c.Assert(rb.servers[2].curWeight, Equals, FSMMaxWeight)

	// server a is now recovering, the weights should go back to the original state
	rb.servers[0].meter.(*testMeter).rating = 0.3
	rb.servers[1].meter.(*testMeter).rating = 0.2
	rb.servers[2].meter.(*testMeter).rating = 0.2

	for i := 0; i < 6; i += 1 {
		testutils.Get(proxy.URL)
		testutils.Get(proxy.URL)
		s.clock.CurrentTime = s.clock.CurrentTime.Add(rb.backoffDuration + time.Second)
	}

	// the algo reverted it back
	c.Assert(rb.servers[0].curWeight, Equals, 1)
	c.Assert(rb.servers[1].curWeight, Equals, 1)
	c.Assert(rb.servers[2].curWeight, Equals, 1)
}
开发者ID:2722,项目名称:lantern,代码行数:54,代码来源:rebalancer_test.go


示例17: TestRebalancerRecovery

// Test scenario when one server goes down after what it recovers
func (s *RBSuite) TestRebalancerRecovery(c *C) {
	a, b := testutils.NewResponder("a"), testutils.NewResponder("b")
	defer a.Close()
	defer b.Close()

	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	newMeter := func() (Meter, error) {
		return &testMeter{}, nil
	}
	rb, err := NewRebalancer(lb, RebalancerMeter(newMeter), RebalancerClock(s.clock), RebalancerLogger(s.log))
	c.Assert(err, IsNil)

	rb.UpsertServer(testutils.ParseURI(a.URL))
	rb.UpsertServer(testutils.ParseURI(b.URL))
	rb.servers[0].meter.(*testMeter).rating = 0.3

	proxy := httptest.NewServer(rb)
	defer proxy.Close()

	for i := 0; i < 6; i += 1 {
		testutils.Get(proxy.URL)
		testutils.Get(proxy.URL)
		s.clock.CurrentTime = s.clock.CurrentTime.Add(rb.backoffDuration + time.Second)
	}

	c.Assert(rb.servers[0].curWeight, Equals, 1)
	c.Assert(rb.servers[1].curWeight, Equals, FSMMaxWeight)

	c.Assert(lb.servers[0].weight, Equals, 1)
	c.Assert(lb.servers[1].weight, Equals, FSMMaxWeight)

	// server a is now recovering, the weights should go back to the original state
	rb.servers[0].meter.(*testMeter).rating = 0

	for i := 0; i < 6; i += 1 {
		testutils.Get(proxy.URL)
		testutils.Get(proxy.URL)
		s.clock.CurrentTime = s.clock.CurrentTime.Add(rb.backoffDuration + time.Second)
	}

	c.Assert(rb.servers[0].curWeight, Equals, 1)
	c.Assert(rb.servers[1].curWeight, Equals, 1)

	// Make sure we have applied the weights to the inner load balancer
	c.Assert(lb.servers[0].weight, Equals, 1)
	c.Assert(lb.servers[1].weight, Equals, 1)
}
开发者ID:2722,项目名称:lantern,代码行数:53,代码来源:rebalancer_test.go


示例18: syncApps

func syncApps(jsontasks *MarathonTasks, jsonapps *MarathonApps) {
	apps.Lock()
	defer apps.Unlock()
	appstmp := make(map[string]App)
	for _, task := range jsontasks.Tasks {
		// Use regex to remove characters that are not allowed in hostnames
		re := regexp.MustCompile("[^0-9a-z-]")
		appid := re.ReplaceAllLiteralString(task.AppId, "")
		apphealth := false
		for _, v := range jsonapps.Apps {
			if v.Id == task.AppId {
				if s, ok := v.Labels["moxy_subdomain"]; ok {
					appid = s
				}
				if len(v.HealthChecks) > 0 {
					apphealth = true
				}
			}
		}
		if apphealth {
			if len(task.HealthCheckResults) == 0 {
				// this means tasks is being deployed but not yet monitored as alive. Assume down.
				continue
			}
			alive := true
			for _, health := range task.HealthCheckResults {
				// check if health check is alive
				if health.Alive == false {
					alive = false
				}
			}
			if alive != true {
				// at least one health check has failed. Assume down.
				continue
			}
		}
		if s, ok := appstmp[appid]; ok {
			s.Lb.UpsertServer(testutils.ParseURI("http://" + task.Host + ":" + strconv.FormatInt(task.Ports[0], 10)))
			s.Tasks = append(s.Tasks, task.Host+":"+strconv.FormatInt(task.Ports[0], 10))
			appstmp[appid] = s
		} else {
			var s = App{}
			s.Fwd, _ = forward.New(forward.PassHostHeader(true))
			s.Lb, _ = roundrobin.New(s.Fwd)
			s.Lb.UpsertServer(testutils.ParseURI("http://" + task.Host + ":" + strconv.FormatInt(task.Ports[0], 10)))
			s.Tasks = []string{task.Host + ":" + strconv.FormatInt(task.Ports[0], 10)}
			appstmp[appid] = s
		}
	}
	apps.Apps = appstmp
}
开发者ID:abhishekamralkar,项目名称:moxy,代码行数:51,代码来源:marathon.go


示例19: TestNoServers

func (s *RRSuite) TestNoServers(c *C) {
	fwd, err := forward.New()
	c.Assert(err, IsNil)

	lb, err := New(fwd)
	c.Assert(err, IsNil)

	proxy := httptest.NewServer(lb)
	defer proxy.Close()

	re, _, err := testutils.Get(proxy.URL)
	c.Assert(err, IsNil)
	c.Assert(re.StatusCode, Equals, http.StatusInternalServerError)
}
开发者ID:2722,项目名称:lantern,代码行数:14,代码来源:rr_test.go


示例20: new

func new(c *C, p string) (*roundrobin.RoundRobin, *Streamer) {
	logger := utils.NewFileLogger(os.Stdout, utils.INFO)
	// forwarder will proxy the request to whatever destination
	fwd, err := forward.New(forward.Logger(logger))
	c.Assert(err, IsNil)

	// load balancer will round robin request
	lb, err := roundrobin.New(fwd)
	c.Assert(err, IsNil)

	// stream handler will forward requests to redirect, make sure it uses files
	st, err := New(lb, Logger(logger), Retry(p), MemRequestBodyBytes(1))
	c.Assert(err, IsNil)

	return lb, st
}
开发者ID:2722,项目名称:lantern,代码行数:16,代码来源:retry_test.go



注:本文中的github.com/mailgun/oxy/forward.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testutils.Get函数代码示例发布时间:2022-05-23
下一篇:
Golang manners.GracefulServer类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap