Don Newton | 379ae25 | 2019-04-01 12:17:06 -0400 | [diff] [blame^] | 1 | // Copyright (C) MongoDB, Inc. 2017-present. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | // not use this file except in compliance with the License. You may obtain |
| 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | |
| 7 | package description |
| 8 | |
| 9 | // ServerKind represents the type of a server. |
| 10 | type ServerKind uint32 |
| 11 | |
| 12 | // These constants are the possible types of servers. |
| 13 | const ( |
| 14 | Standalone ServerKind = 1 |
| 15 | RSMember ServerKind = 2 |
| 16 | RSPrimary ServerKind = 4 + RSMember |
| 17 | RSSecondary ServerKind = 8 + RSMember |
| 18 | RSArbiter ServerKind = 16 + RSMember |
| 19 | RSGhost ServerKind = 32 + RSMember |
| 20 | Mongos ServerKind = 256 |
| 21 | ) |
| 22 | |
| 23 | // String implements the fmt.Stringer interface. |
| 24 | func (kind ServerKind) String() string { |
| 25 | switch kind { |
| 26 | case Standalone: |
| 27 | return "Standalone" |
| 28 | case RSMember: |
| 29 | return "RSOther" |
| 30 | case RSPrimary: |
| 31 | return "RSPrimary" |
| 32 | case RSSecondary: |
| 33 | return "RSSecondary" |
| 34 | case RSArbiter: |
| 35 | return "RSArbiter" |
| 36 | case RSGhost: |
| 37 | return "RSGhost" |
| 38 | case Mongos: |
| 39 | return "Mongos" |
| 40 | } |
| 41 | |
| 42 | return "Unknown" |
| 43 | } |