mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	proxy: Correct policy documentation (#1678)
* Correct proxy policy documentation Signed-off-by: Jonas Östanbäck <jonas.ostanback@gmail.com> * Change first's select() wording Signed-off-by: Jonas Östanbäck <jonas.ostanback@gmail.com>
This commit is contained in:
		
							parent
							
								
									05ea5c32be
								
							
						
					
					
						commit
						8d3f336971
					
				| @ -84,13 +84,13 @@ func (r *LeastConn) Select(pool HostPool, request *http.Request) *UpstreamHost { | ||||
| 	return bestHost | ||||
| } | ||||
| 
 | ||||
| // RoundRobin is a policy that selects hosts based on round robin ordering. | ||||
| // RoundRobin is a policy that selects hosts based on round-robin ordering. | ||||
| type RoundRobin struct { | ||||
| 	robin uint32 | ||||
| 	mutex sync.Mutex | ||||
| } | ||||
| 
 | ||||
| // Select selects an up host from the pool using a round robin ordering scheme. | ||||
| // Select selects an up host from the pool using a round-robin ordering scheme. | ||||
| func (r *RoundRobin) Select(pool HostPool, request *http.Request) *UpstreamHost { | ||||
| 	poolLen := uint32(len(pool)) | ||||
| 	r.mutex.Lock() | ||||
| @ -106,7 +106,7 @@ func (r *RoundRobin) Select(pool HostPool, request *http.Request) *UpstreamHost | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // IPHash is a policy that selects hosts based on hashing the request ip | ||||
| // IPHash is a policy that selects hosts based on hashing the request IP | ||||
| type IPHash struct{} | ||||
| 
 | ||||
| func hash(s string) uint32 { | ||||
| @ -115,7 +115,7 @@ func hash(s string) uint32 { | ||||
| 	return h.Sum32() | ||||
| } | ||||
| 
 | ||||
| // Select selects an up host from the pool using a round robin ordering scheme. | ||||
| // Select selects an up host from the pool based on hashing the request IP | ||||
| func (r *IPHash) Select(pool HostPool, request *http.Request) *UpstreamHost { | ||||
| 	poolLen := uint32(len(pool)) | ||||
| 	clientIP, _, err := net.SplitHostPort(request.RemoteAddr) | ||||
| @ -133,10 +133,10 @@ func (r *IPHash) Select(pool HostPool, request *http.Request) *UpstreamHost { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // First is a policy that selects the fist available host | ||||
| // First is a policy that selects the first available host | ||||
| type First struct{} | ||||
| 
 | ||||
| // Select selects the first host from the pool, that is available | ||||
| // Select selects the first available host from the pool | ||||
| func (r *First) Select(pool HostPool, request *http.Request) *UpstreamHost { | ||||
| 	for _, host := range pool { | ||||
| 		if host.Available() { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user