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 | // TopologyKind represents a specific topology configuration. |
| 10 | type TopologyKind uint32 |
| 11 | |
| 12 | // These constants are the available topology configurations. |
| 13 | const ( |
| 14 | Single TopologyKind = 1 |
| 15 | ReplicaSet TopologyKind = 2 |
| 16 | ReplicaSetNoPrimary TopologyKind = 4 + ReplicaSet |
| 17 | ReplicaSetWithPrimary TopologyKind = 8 + ReplicaSet |
| 18 | Sharded TopologyKind = 256 |
| 19 | ) |
| 20 | |
| 21 | // String implements the fmt.Stringer interface. |
| 22 | func (kind TopologyKind) String() string { |
| 23 | switch kind { |
| 24 | case Single: |
| 25 | return "Single" |
| 26 | case ReplicaSet: |
| 27 | return "ReplicaSet" |
| 28 | case ReplicaSetNoPrimary: |
| 29 | return "ReplicaSetNoPrimary" |
| 30 | case ReplicaSetWithPrimary: |
| 31 | return "ReplicaSetWithPrimary" |
| 32 | case Sharded: |
| 33 | return "Sharded" |
| 34 | } |
| 35 | |
| 36 | return "Unknown" |
| 37 | } |