forked from yuxh/gearman-go
		
	Allow built in selectionHandlers to be reused outside of package
This commit is contained in:
		
							parent
							
								
									1c4b8aa000
								
							
						
					
					
						commit
						9d99accce2
					
				@ -11,9 +11,7 @@ const (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	ErrNotFound    = errors.New("Server Not Found")
 | 
						ErrNotFound = errors.New("Server Not Found")
 | 
				
			||||||
	SelectWithRate = selectWithRate
 | 
					 | 
				
			||||||
	SelectRandom   = selectRandom
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type PoolClient struct {
 | 
					type PoolClient struct {
 | 
				
			||||||
@ -24,7 +22,7 @@ type PoolClient struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type SelectionHandler func(map[string]*PoolClient, string) string
 | 
					type SelectionHandler func(map[string]*PoolClient, string) string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func selectWithRate(pool map[string]*PoolClient,
 | 
					func SelectWithRate(pool map[string]*PoolClient,
 | 
				
			||||||
	last string) (addr string) {
 | 
						last string) (addr string) {
 | 
				
			||||||
	total := 0
 | 
						total := 0
 | 
				
			||||||
	for _, item := range pool {
 | 
						for _, item := range pool {
 | 
				
			||||||
@ -36,7 +34,7 @@ func selectWithRate(pool map[string]*PoolClient,
 | 
				
			|||||||
	return last
 | 
						return last
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func selectRandom(pool map[string]*PoolClient,
 | 
					func SelectRandom(pool map[string]*PoolClient,
 | 
				
			||||||
	last string) (addr string) {
 | 
						last string) (addr string) {
 | 
				
			||||||
	r := rand.Intn(len(pool))
 | 
						r := rand.Intn(len(pool))
 | 
				
			||||||
	i := 0
 | 
						i := 0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user