Documentation
¶
Overview ¶
Package connstring is intended for internal use only. It is made available to facilitate use cases that require access to internal MongoDB driver functionality and state. The API of this package is not stable and there is no backward compatibility guarantee.
WARNING: THIS PACKAGE IS EXPERIMENTAL AND MAY BE MODIFIED OR REMOVED WITHOUT NOTICE! USE WITH EXTREME CAUTION!
Index ¶
Constants ¶
const ( // ServerMonitoringModeAuto indicates that the client will behave like "poll" // mode when running on a FaaS (Function as a Service) platform, or like // "stream" mode otherwise. The client detects its execution environment by // following the rules for generating the "client.env" handshake metadata field // as specified in the MongoDB Handshake specification. This is the default // mode. ServerMonitoringModeAuto = "auto" // ServerMonitoringModePoll indicates that the client will periodically check // the server using a hello or legacy hello command and then sleep for // heartbeatFrequencyMS milliseconds before running another check. ServerMonitoringModePoll = "poll" // ServerMonitoringModeStream indicates that the client will use a streaming // protocol when the server supports it. The streaming protocol optimally // reduces the time it takes for a client to discover server state changes. ServerMonitoringModeStream = "stream" )
const ( SchemeMongoDB = "mongodb" SchemeMongoDBSRV = "mongodb+srv" )
Scheme constants
Variables ¶
var ( // ErrLoadBalancedWithMultipleHosts is returned when loadBalanced=true is // specified in a URI with multiple hosts. ErrLoadBalancedWithMultipleHosts = errors.New( "loadBalanced cannot be set to true if multiple hosts are specified") // ErrLoadBalancedWithReplicaSet is returned when loadBalanced=true is // specified in a URI with the replicaSet option. ErrLoadBalancedWithReplicaSet = errors.New( "loadBalanced cannot be set to true if a replica set name is specified") // ErrLoadBalancedWithDirectConnection is returned when loadBalanced=true is // specified in a URI with the directConnection option. ErrLoadBalancedWithDirectConnection = errors.New( "loadBalanced cannot be set to true if the direct connection option is specified") // ErrSRVMaxHostsWithReplicaSet is returned when srvMaxHosts > 0 is // specified in a URI with the replicaSet option. ErrSRVMaxHostsWithReplicaSet = errors.New( "srvMaxHosts cannot be a positive value if a replica set name is specified") // ErrSRVMaxHostsWithLoadBalanced is returned when srvMaxHosts > 0 is // specified in a URI with loadBalanced=true. ErrSRVMaxHostsWithLoadBalanced = errors.New( "srvMaxHosts cannot be a positive value if loadBalanced is set to true") )
Functions ¶
Types ¶
type ConnString ¶
type ConnString struct {
Original string
AppName string
AuthMechanism string
AuthMechanismProperties map[string]string
AuthMechanismPropertiesSet bool
AuthSource string
AuthSourceSet bool
Compressors []string
Connect ConnectMode
ConnectSet bool
DirectConnection bool
DirectConnectionSet bool
ConnectTimeout time.Duration
ConnectTimeoutSet bool
Database string
HeartbeatInterval time.Duration
HeartbeatIntervalSet bool
Hosts []string
J bool
JSet bool
LoadBalanced bool
LoadBalancedSet bool
LocalThreshold time.Duration
LocalThresholdSet bool
MaxConnIdleTime time.Duration
MaxConnIdleTimeSet bool
MaxPoolSize uint64
MaxPoolSizeSet bool
MinPoolSize uint64
MinPoolSizeSet bool
MaxConnecting uint64
MaxConnectingSet bool
Password string
PasswordSet bool
RawHosts []string
ReadConcernLevel string
ReadPreference string
ReadPreferenceTagSets []map[string]string
RetryWrites bool
RetryWritesSet bool
RetryReads bool
RetryReadsSet bool
MaxStaleness time.Duration
MaxStalenessSet bool
ReplicaSet string
Scheme string
ServerMonitoringMode string
ServerSelectionTimeout time.Duration
ServerSelectionTimeoutSet bool
SocketTimeout time.Duration
SocketTimeoutSet bool
SRVMaxHosts int
SRVServiceName string
SSL bool
SSLSet bool
SSLClientCertificateKeyFile string
SSLClientCertificateKeyFileSet bool
SSLClientCertificateKeyPassword func() string
SSLClientCertificateKeyPasswordSet bool
SSLCertificateFile string
SSLCertificateFileSet bool
SSLPrivateKeyFile string
SSLPrivateKeyFileSet bool
SSLInsecure bool
SSLInsecureSet bool
SSLCaFile string
SSLCaFileSet bool
SSLDisableOCSPEndpointCheck bool
SSLDisableOCSPEndpointCheckSet bool
Timeout time.Duration
TimeoutSet bool
WString string
WNumber int
WNumberSet bool
Username string
UsernameSet bool
ZlibLevel int
ZlibLevelSet bool
ZstdLevel int
ZstdLevelSet bool
Options map[string][]string
UnknownOptions map[string][]string
}
ConnString represents a connection string to mongodb.
func Parse ¶
func Parse(s string) (*ConnString, error)
Parse parses the provided URI into a ConnString object but does not check that all values are valid. Use `ConnString.Validate()` to run the validation checks separately.
func ParseAndValidate ¶
func ParseAndValidate(s string) (*ConnString, error)
ParseAndValidate parses the provided URI into a ConnString object. It check that all values are valid.
func (*ConnString) HasAuthParameters ¶
func (u *ConnString) HasAuthParameters() bool
HasAuthParameters returns true if this ConnString has any authentication parameters set and therefore represents a request for authentication.
func (*ConnString) String ¶
func (u *ConnString) String() string
func (*ConnString) Validate ¶
func (u *ConnString) Validate() error
Validate checks that the Auth and SSL parameters are valid values.
type ConnectMode ¶
type ConnectMode uint8
ConnectMode informs the driver on how to connect to the server.
const ( AutoConnect ConnectMode = iota SingleConnect )
ConnectMode constants.
func (ConnectMode) String ¶
func (c ConnectMode) String() string
String implements the fmt.Stringer interface.
Source Files
¶
- connstring.go