예제 #1
0
func initGroupcacheHTTPPool() {
	self := (&url.URL{Scheme: "http", Host: flagHTTP}).String()
	var peers []string
	peers = append(peers, self)
	for _, p := range strings.Split(flagGroupcachePeers, ",") {
		if p == "" {
			continue
		}
		peer := (&url.URL{Scheme: "http", Host: p}).String()
		peers = append(peers, peer)
	}
	pool := groupcache.NewHTTPPool(self)
	pool.Context = imageserver_cache_groupcache.HTTPPoolContext
	pool.Transport = imageserver_cache_groupcache.NewHTTPPoolTransport(nil)
	pool.Set(peers...)
}
예제 #2
0
func newGroupcacheHTTPPool() *groupcache.HTTPPool {
	self := (&url.URL{Scheme: "http", Host: flagGroupcacheSelf}).String()
	var peers []string
	peers = append(peers, self)
	for _, p := range strings.Split(flagGroupcachePeers, ",") {
		if p == "" {
			continue
		}
		peer := (&url.URL{Scheme: "http", Host: p}).String()
		peers = append(peers, peer)
	}
	opts := &groupcache.HTTPPoolOptions{BasePath: "/"}
	pool := groupcache.NewHTTPPoolOpts(self, opts)
	pool.Context = imageserver_cache_groupcache.HTTPPoolContext
	pool.Transport = imageserver_cache_groupcache.NewHTTPPoolTransport(nil)
	pool.Set(peers...)
	return pool
}