forked from smallnest/rpcx
/
mode.go
49 lines (42 loc) · 1.16 KB
/
mode.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
40
41
42
43
44
45
46
47
48
49
package client
//FailMode decides how clients action when clients fail to invoke services
type FailMode int
const (
//Failover selects another server automaticaly
Failover FailMode = iota
//Failfast returns error immediately
Failfast
//Failtry use current client again
Failtry
//Failbackup select another server if the first server doesn't respon in specified time and use the fast response.
Failbackup
)
// SelectMode defines the algorithm of selecting a services from candidates.
type SelectMode int
const (
//RandomSelect is selecting randomly
RandomSelect SelectMode = iota
//RoundRobin is selecting by round robin
RoundRobin
//WeightedRoundRobin is selecting by weighted round robin
WeightedRoundRobin
//WeightedICMP is selecting by weighted Ping time
WeightedICMP
//ConsistentHash is selecting by hashing
ConsistentHash
//Closest is selecting the closest server
Closest
// SelectByUser is selecting by implementation of users
SelectByUser = 1000
)
var selectModeStrs = [...]string{
"RandomSelect",
"RoundRobin",
"WeightedRoundRobin",
"WeightedICMP",
"ConsistentHash",
"Closest",
}
func (s SelectMode) String() string {
return selectModeStrs[s]
}