Documentation ¶
Index ¶
- type Client
- type ClientBundle
- func (cb *ClientBundle) AppName(s string) *ClientBundle
- func (cb *ClientBundle) Auth(auth Credential) *ClientBundle
- func (cb *ClientBundle) ConnectTimeout(d time.Duration) *ClientBundle
- func (cb *ClientBundle) Dialer(d ContextDialer) *ClientBundle
- func (cb *ClientBundle) HeartbeatInterval(d time.Duration) *ClientBundle
- func (cb *ClientBundle) Hosts(s []string) *ClientBundle
- func (cb *ClientBundle) LocalThreshold(d time.Duration) *ClientBundle
- func (cb *ClientBundle) MaxConnIdleTime(d time.Duration) *ClientBundle
- func (cb *ClientBundle) MaxConnsPerHost(u uint16) *ClientBundle
- func (cb *ClientBundle) MaxIdleConnsPerHost(u uint16) *ClientBundle
- func (cb *ClientBundle) Monitor(m *event.CommandMonitor) *ClientBundle
- func (cb *ClientBundle) ReadConcern(rc *readconcern.ReadConcern) *ClientBundle
- func (cb *ClientBundle) ReadPreference(rp *readpref.ReadPref) *ClientBundle
- func (cb *ClientBundle) ReplicaSet(s string) *ClientBundle
- func (cb *ClientBundle) RetryWrites(b bool) *ClientBundle
- func (cb *ClientBundle) SSL(ssl *SSLOpt) *ClientBundle
- func (cb *ClientBundle) ServerSelectionTimeout(d time.Duration) *ClientBundle
- func (cb *ClientBundle) Single(b bool) *ClientBundle
- func (cb *ClientBundle) SocketTimeout(d time.Duration) *ClientBundle
- func (cb *ClientBundle) String() string
- func (cb *ClientBundle) Unbundle(connString connstring.ConnString) (*Client, error)
- func (cb *ClientBundle) WriteConcern(wc *writeconcern.WriteConcern) *ClientBundle
- type ContextDialer
- type Credential
- type Option
- func AppName(s string) Option
- func Auth(auth Credential) Option
- func ConnectTimeout(d time.Duration) Option
- func Dialer(d ContextDialer) Option
- func HeartbeatInterval(d time.Duration) Option
- func Hosts(s []string) Option
- func LocalThreshold(d time.Duration) Option
- func MaxConnIdleTime(d time.Duration) Option
- func MaxConnsPerHost(u uint16) Option
- func MaxIdleConnsPerHost(u uint16) Option
- func Monitor(m *event.CommandMonitor) Option
- func ReadConcern(rc *readconcern.ReadConcern) Option
- func ReadPreference(rp *readpref.ReadPref) Option
- func ReplicaSet(s string) Option
- func RetryWrites(b bool) Option
- func SSL(ssl *SSLOpt) Option
- func ServerSelectionTimeout(d time.Duration) Option
- func Single(b bool) Option
- func SocketTimeout(d time.Duration) Option
- func WriteConcern(wc *writeconcern.WriteConcern) Option
- type SSLOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { TopologyOptions []topology.Option ConnString connstring.ConnString RetryWrites bool RetryWritesSet bool ReadPreference *readpref.ReadPref ReadConcern *readconcern.ReadConcern WriteConcern *writeconcern.WriteConcern }
Client represents a client
type ClientBundle ¶
type ClientBundle struct {
// contains filtered or unexported fields
}
ClientBundle is a bundle of client options
func BundleClient ¶
func BundleClient(opts ...Option) *ClientBundle
BundleClient bundles client options
func (*ClientBundle) AppName ¶
func (cb *ClientBundle) AppName(s string) *ClientBundle
AppName specifies the client application name. This value is used by MongoDB when it logs connection information and profile information, such as slow queries.
func (*ClientBundle) Auth ¶
func (cb *ClientBundle) Auth(auth Credential) *ClientBundle
Auth sets the authentication properties.
func (*ClientBundle) ConnectTimeout ¶
func (cb *ClientBundle) ConnectTimeout(d time.Duration) *ClientBundle
ConnectTimeout specifies the timeout for an initial connection to a server. If a custom Dialer is used, this method won't be set and the user is responsible for setting the ConnectTimeout for connections on the dialer themselves.
func (*ClientBundle) Dialer ¶
func (cb *ClientBundle) Dialer(d ContextDialer) *ClientBundle
Dialer specifies a custom dialer used to dial new connections to a server.
func (*ClientBundle) HeartbeatInterval ¶
func (cb *ClientBundle) HeartbeatInterval(d time.Duration) *ClientBundle
HeartbeatInterval specifies the interval to wait between server monitoring checks.
func (*ClientBundle) Hosts ¶
func (cb *ClientBundle) Hosts(s []string) *ClientBundle
Hosts specifies the initial list of addresses from which to discover the rest of the cluster.
func (*ClientBundle) LocalThreshold ¶
func (cb *ClientBundle) LocalThreshold(d time.Duration) *ClientBundle
LocalThreshold specifies how far to distribute queries, beyond the server with the fastest round-trip time. If a server's roundtrip time is more than LocalThreshold slower than the the fastest, the driver will not send queries to that server.
func (*ClientBundle) MaxConnIdleTime ¶
func (cb *ClientBundle) MaxConnIdleTime(d time.Duration) *ClientBundle
MaxConnIdleTime specifies the maximum number of milliseconds that a connection can remain idle in a connection pool before being removed and closed.
func (*ClientBundle) MaxConnsPerHost ¶
func (cb *ClientBundle) MaxConnsPerHost(u uint16) *ClientBundle
MaxConnsPerHost specifies the max size of a server's connection pool.
func (*ClientBundle) MaxIdleConnsPerHost ¶
func (cb *ClientBundle) MaxIdleConnsPerHost(u uint16) *ClientBundle
MaxIdleConnsPerHost specifies the number of connections in a server's connection pool that can be idle at any given time.
func (*ClientBundle) Monitor ¶ added in v0.0.10
func (cb *ClientBundle) Monitor(m *event.CommandMonitor) *ClientBundle
Monitor specifies a command monitor for this client.
func (*ClientBundle) ReadConcern ¶
func (cb *ClientBundle) ReadConcern(rc *readconcern.ReadConcern) *ClientBundle
ReadConcern specifies the read concern.
func (*ClientBundle) ReadPreference ¶
func (cb *ClientBundle) ReadPreference(rp *readpref.ReadPref) *ClientBundle
ReadPreference specifies the read preference.
func (*ClientBundle) ReplicaSet ¶
func (cb *ClientBundle) ReplicaSet(s string) *ClientBundle
ReplicaSet specifies the name of the replica set of the cluster.
func (*ClientBundle) RetryWrites ¶ added in v0.0.12
func (cb *ClientBundle) RetryWrites(b bool) *ClientBundle
RetryWrites specifies whether the client has retryable writes enabled.
func (*ClientBundle) SSL ¶
func (cb *ClientBundle) SSL(ssl *SSLOpt) *ClientBundle
SSL sets SSL options.
func (*ClientBundle) ServerSelectionTimeout ¶
func (cb *ClientBundle) ServerSelectionTimeout(d time.Duration) *ClientBundle
ServerSelectionTimeout specifies a timeout in milliseconds to block for server selection.
func (*ClientBundle) Single ¶
func (cb *ClientBundle) Single(b bool) *ClientBundle
Single specifies whether the driver should connect directly to the server instead of auto-discovering other servers in the cluster.
func (*ClientBundle) SocketTimeout ¶
func (cb *ClientBundle) SocketTimeout(d time.Duration) *ClientBundle
SocketTimeout specifies the time in milliseconds to attempt to send or receive on a socket before the attempt times out.
func (*ClientBundle) String ¶
func (cb *ClientBundle) String() string
String prints a string representation of the bundle for debug purposes.
func (*ClientBundle) Unbundle ¶
func (cb *ClientBundle) Unbundle(connString connstring.ConnString) (*Client, error)
Unbundle transforms a client given a connectionstring.
func (*ClientBundle) WriteConcern ¶
func (cb *ClientBundle) WriteConcern(wc *writeconcern.WriteConcern) *ClientBundle
WriteConcern specifies the write concern.
type ContextDialer ¶
type ContextDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
ContextDialer makes new network connections
type Credential ¶
type Credential struct { AuthMechanism string AuthMechanismProperties map[string]string AuthSource string Username string Password string }
Credential holds auth options.
AuthMechanism indicates the mechanism to use for authentication. Supported values include "SCRAM-SHA-256", "SCRAM-SHA-1", "MONGODB-CR", "PLAIN", "GSSAPI", and "MONGODB-X509".
AuthMechanismProperties specifies additional configuration options which may be used by certain authentication mechanisms.
AuthSource specifies the database to authenticate against.
Username specifies the username that will be authenticated.
Password specifies the password used for authentication.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option represents a client option
func AppName ¶
AppName specifies the client application name. This value is used by MongoDB when it logs connection information and profile information, such as slow queries.
func ConnectTimeout ¶
ConnectTimeout specifies the timeout for an initial connection to a server. If a custom Dialer is used, this method won't be set and the user is responsible for setting the ConnectTimeout for connections on the dialer themselves.
func Dialer ¶
func Dialer(d ContextDialer) Option
Dialer specifies a custom dialer used to dial new connections to a server.
func HeartbeatInterval ¶
HeartbeatInterval specifies the interval to wait between server monitoring checks.
func Hosts ¶
Hosts specifies the initial list of addresses from which to discover the rest of the cluster.
func LocalThreshold ¶
LocalThreshold specifies how far to distribute queries, beyond the server with the fastest round-trip time. If a server's roundtrip time is more than LocalThreshold slower than the the fastest, the driver will not send queries to that server.
func MaxConnIdleTime ¶
MaxConnIdleTime specifies the maximum number of milliseconds that a connection can remain idle in a connection pool before being removed and closed.
func MaxConnsPerHost ¶
MaxConnsPerHost specifies the max size of a server's connection pool.
func MaxIdleConnsPerHost ¶
MaxIdleConnsPerHost specifies the number of connections in a server's connection pool that can be idle at any given time.
func Monitor ¶ added in v0.0.10
func Monitor(m *event.CommandMonitor) Option
Monitor specifies a command monitor used to see commands for a client.
func ReadConcern ¶
func ReadConcern(rc *readconcern.ReadConcern) Option
ReadConcern specifies the read concern.
func ReadPreference ¶
ReadPreference specifies the read preference
func ReplicaSet ¶
ReplicaSet specifies the name of the replica set of the cluster.
func RetryWrites ¶ added in v0.0.12
RetryWrites specifies whether the client has retryable writes enabled.
func ServerSelectionTimeout ¶
ServerSelectionTimeout specifies a timeout in milliseconds to block for server selection.
func Single ¶
Single specifies whether the driver should connect directly to the server instead of auto-discovering other servers in the cluster.
func SocketTimeout ¶
SocketTimeout specifies the time in milliseconds to attempt to send or receive on a socket before the attempt times out.
func WriteConcern ¶
func WriteConcern(wc *writeconcern.WriteConcern) Option
WriteConcern sets the write concern.
type SSLOpt ¶
type SSLOpt struct { Enabled bool ClientCertificateKeyFile string ClientCertificateKeyPassword func() string Insecure bool CaFile string }
SSLOpt holds client SSL options.
Enabled indicates whether SSL should be enabled.
ClientCertificateKeyFile specifies the file containing the client certificate and private key used for authentication.
ClientCertificateKeyPassword provides a callback that returns a password used for decrypting the private key of a PEM file (if one is provided).
Insecure indicates whether to skip the verification of the server certificate and hostname.
CaFile specifies the file containing the certificate authority used for SSL connections.