-
Notifications
You must be signed in to change notification settings - Fork 25
/
balance.go
39 lines (32 loc) · 952 Bytes
/
balance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Scry Info. All rights reserved.
// license that can be found in the license file.
package lb
import (
"strings"
"google.golang.org/grpc"
)
const (
Round = "round"
First = "first"
)
//If not found, then return Round Balance
func Balance(bname string) grpc.DialOption {
var do grpc.DialOption = nil
switch strings.ToLower(bname) {
case Round:
do = BalancerRound()
case First:
do = BalancerFirst()
default:
do = BalancerRound()
}
return do
}
func BalancerRound() grpc.DialOption { //todo grpc realization balance management use global variables, and do not consider multi thread condition, this is a temporary point
//return grpc.WithBalancerName(roundrobin.Name)
return nil
}
func BalancerFirst() grpc.DialOption { //todo grpc realization balance management use global variables, and do not consider multi thread condition, this is a temporary point
//return grpc.WithBalancerName(grpc.PickFirstBalancerName)
return nil
}