blob: 463ddc2a5c1ca26bf3a912165d659aa3c1753c3d [file] [log] [blame]
William Kurkianea869482019-04-09 15:16:11 -04001// Copyright 2018 The etcd Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package picker
16
17import "fmt"
18
19// Policy defines balancer picker policy.
20type Policy uint8
21
22const (
23 // TODO: custom picker is not supported yet.
24 // custom defines custom balancer picker.
25 custom Policy = iota
26
27 // RoundrobinBalanced balance loads over multiple endpoints
28 // and implements failover in roundrobin fashion.
29 RoundrobinBalanced Policy = iota
30
31 // TODO: only send loads to pinned address "RoundrobinFailover"
32 // just like how 3.3 client works
33 //
34 // TODO: priotize leader
35 // TODO: health-check
36 // TODO: weighted roundrobin
37 // TODO: power of two random choice
38)
39
40func (p Policy) String() string {
41 switch p {
42 case custom:
43 panic("'custom' picker policy is not supported yet")
44 case RoundrobinBalanced:
45 return "etcd-client-roundrobin-balanced"
46 default:
47 panic(fmt.Errorf("invalid balancer picker policy (%d)", p))
48 }
49}