...

Source file src/go.mongodb.org/mongo-driver/mongo/description/server_kind.go

Documentation: go.mongodb.org/mongo-driver/mongo/description

     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 single server in a topology.
    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  	LoadBalancer ServerKind = 512
    22  )
    23  
    24  // String returns a stringified version of the kind or "Unknown" if the kind is invalid.
    25  func (kind ServerKind) String() string {
    26  	switch kind {
    27  	case Standalone:
    28  		return "Standalone"
    29  	case RSMember:
    30  		return "RSOther"
    31  	case RSPrimary:
    32  		return "RSPrimary"
    33  	case RSSecondary:
    34  		return "RSSecondary"
    35  	case RSArbiter:
    36  		return "RSArbiter"
    37  	case RSGhost:
    38  		return "RSGhost"
    39  	case Mongos:
    40  		return "Mongos"
    41  	case LoadBalancer:
    42  		return "LoadBalancer"
    43  	}
    44  
    45  	return "Unknown"
    46  }
    47  

View as plain text