예제 #1
0
func main() {
	config := backend.PoolConfig{
		HealthzEvery:   1 * time.Second,
		HealthzTimeout: 1 * time.Second,
		RequestTimeout: 5 * time.Second,
		Status:         "OK",
	}

	/*
		prof, err := os.Create("profile")
		pprof.StartCPUProfile()

		sigINT := make(chan os.Signal, 1)
		signal.Notify(sigINT, os.Interrupt)
		go func(){
			for s := range sigINT{
				pprof.StopCPUProfile()
				os.Exit(0)
			}
		}()
	*/

	pool := backend.NewPool("routertest", config)

	for _, server := range servers {
		pool.AddServer(server, backend.NewServer(server))
	}

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		pool.Handle(w, r)
	})

	log.Fatal(http.ListenAndServe(":8080", nil))
}
예제 #2
0
func (c *Config) ConstructPool(pool Pool) *backend.Pool {
	return backend.NewPool(pool.Name, c.ConstructPoolConfig(pool))
}