コード例 #1
0
ファイル: distributer.go プロジェクト: ROOT005/ants-go
// if cookiejar > 0 means it require cookie context ,so we should send it to where it come from
// else distribute it by order
func (this *Distributer) Distribute(request *http.Request) {
	if request.CookieJar > 0 {
		return
	} else {
		nodeList := this.Cluster.GetAllNode()
		if this.LastIndex >= len(nodeList) {
			this.LastIndex = 0
		}
		nodeName := nodeList[this.LastIndex].Name
		request.NodeName = nodeName
		this.LastIndex += 1
	}
}