Documentation
¶
Index ¶
- type Config
- type Option
- func WithAppName(appName string) Option
- func WithConnectTimeout(timeout time.Duration) Option
- func WithDatabase(database string) Option
- func WithDebug(debug bool) Option
- func WithDirectConnection(direct bool) Option
- func WithHeartbeatInterval(interval time.Duration) Option
- func WithMaxConnIdleTime(duration time.Duration) Option
- func WithMaxPoolSize(size uint64) Option
- func WithMinPoolSize(size uint64) Option
- func WithReadPreference(preference string) Option
- func WithReplicaSet(replicaSet string) Option
- func WithRetryReads(retry bool) Option
- func WithRetryWrites(retry bool) Option
- func WithServerSelectionTimeout(timeout time.Duration) Option
- func WithSocketTimeout(timeout time.Duration) Option
- func WithTimeout(timeout time.Duration) Option
- func WithURI(uri string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Connection settings
URI string // MongoDB connection URI (required)
Database string // Default database name (required)
// Connection pool settings
MaxPoolSize uint64 // Maximum number of connections in the pool
MinPoolSize uint64 // Minimum number of connections in the pool
// Timeout settings
ConnectTimeout time.Duration // Timeout for establishing connection
ServerSelectionTimeout time.Duration // Timeout for selecting server
SocketTimeout time.Duration // Timeout for socket operations
Timeout time.Duration // Default timeout for operations
// Additional settings
Debug bool // Enable debug logging
RetryWrites bool // Enable automatic retry of write operations
RetryReads bool // Enable automatic retry of read operations
AppName string // Application name for MongoDB logs
DirectConnection bool // Whether to connect directly to a single host
ReplicaSet string // Replica set name (optional)
ReadPreference string // Read preference mode (primary, secondary, etc.)
MaxConnIdleTime time.Duration // Maximum idle time for connection
HeartbeatInterval time.Duration // Interval between server heartbeats
}
func DefaultConfig ¶
func DefaultConfig() Config
type Option ¶
type Option func(*Config)
func WithAppName ¶
func WithConnectTimeout ¶
func WithDatabase ¶
func WithDirectConnection ¶
func WithHeartbeatInterval ¶
func WithMaxConnIdleTime ¶
func WithMaxPoolSize ¶
func WithMinPoolSize ¶
func WithReadPreference ¶
func WithReplicaSet ¶
func WithRetryReads ¶
func WithRetryWrites ¶
func WithSocketTimeout ¶
func WithTimeout ¶
Click to show internal directories.
Click to hide internal directories.