William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 1 | // 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 | |
| 15 | package picker |
| 16 | |
| 17 | import "fmt" |
| 18 | |
| 19 | // Policy defines balancer picker policy. |
| 20 | type Policy uint8 |
| 21 | |
| 22 | const ( |
| 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 | // |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame] | 34 | // TODO: prioritize leader |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 35 | // TODO: health-check |
| 36 | // TODO: weighted roundrobin |
| 37 | // TODO: power of two random choice |
| 38 | ) |
| 39 | |
| 40 | func (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 | } |