clientopt

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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
	Registry        *bsoncodec.Registry
}

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) Registry added in v0.0.15

func (cb *ClientBundle) Registry(registry *bsoncodec.Registry) *ClientBundle

Registry specifies the bsoncodec.Registry.

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

func AppName(s string) Option

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 Auth

func Auth(auth Credential) Option

Auth sets the authentication options.

func ConnectTimeout

func ConnectTimeout(d time.Duration) Option

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

func HeartbeatInterval(d time.Duration) Option

HeartbeatInterval specifies the interval to wait between server monitoring checks.

func Hosts

func Hosts(s []string) Option

Hosts specifies the initial list of addresses from which to discover the rest of the cluster.

func LocalThreshold

func LocalThreshold(d time.Duration) Option

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

func MaxConnIdleTime(d time.Duration) Option

MaxConnIdleTime specifies the maximum number of milliseconds that a connection can remain idle in a connection pool before being removed and closed.

func MaxConnsPerHost

func MaxConnsPerHost(u uint16) Option

MaxConnsPerHost specifies the max size of a server's connection pool.

func MaxIdleConnsPerHost

func MaxIdleConnsPerHost(u uint16) Option

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

func ReadPreference(rp *readpref.ReadPref) Option

ReadPreference specifies the read preference.

func Registry added in v0.0.15

func Registry(registry *bsoncodec.Registry) Option

Registry specifies the bsoncodec.Registry.

func ReplicaSet

func ReplicaSet(s string) Option

ReplicaSet specifies the name of the replica set of the cluster.

func RetryWrites added in v0.0.12

func RetryWrites(b bool) Option

RetryWrites specifies whether the client has retryable writes enabled.

func SSL

func SSL(ssl *SSLOpt) Option

SSL sets SSL options.

func ServerSelectionTimeout

func ServerSelectionTimeout(d time.Duration) Option

ServerSelectionTimeout specifies a timeout in milliseconds to block for server selection.

func Single

func Single(b bool) Option

Single specifies whether the driver should connect directly to the server instead of auto-discovering other servers in the cluster.

func SocketTimeout

func SocketTimeout(d time.Duration) Option

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL