Documentation ¶
Overview ¶
Package server is not for public use.
The API for packages in the 'private' directory have no stability guarantee.
The packages within the 'private' directory would normally be put into an 'internal' directory to prohibit their use outside the 'mongo' directory. However, some MongoDB tools require very low-level access to the building blocks of a driver, so we have placed them under 'private' to allow these packages to be imported by projects that need them.
These package APIs may be modified in backwards-incompatible ways at any time.
You are strongly discouraged from directly using any packages under 'private'.
Index ¶
- Variables
- type Monitor
- type Option
- func WithConnectionOpener(opener conn.Opener) Option
- func WithConnectionOptions(opts ...conn.Option) Option
- func WithHeartbeatInterval(interval time.Duration) Option
- func WithHeartbeatTimeout(timeout time.Duration) Option
- func WithMaxConnections(max uint16) Option
- func WithMaxIdleConnections(size uint16) Option
- func WithMoreConnectionOptions(opts ...conn.Option) Option
- func WithWrappedConnectionOpener(wrapper func(conn.Opener) conn.Opener) Option
- type Server
Constants ¶
This section is empty.
Variables ¶
var ErrServerClosed = errors.New("server is closed")
ErrServerClosed occurs when an attempt to get a connection is made after the server has been closed.
Functions ¶
This section is empty.
Types ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor holds a channel that delivers updates to a server.
func StartMonitor ¶
StartMonitor returns a new Monitor.
func (*Monitor) RequestImmediateCheck ¶
func (m *Monitor) RequestImmediateCheck()
RequestImmediateCheck will cause the Monitor to send a heartbeat to the server right away, instead of waiting for the heartbeat timeout.
func (*Monitor) Subscribe ¶
Subscribe returns a channel on which all updated server descriptions will be sent. The channel will have a buffer size of one, and will be pre-populated with the current description. Subscribe also returns a function that, when called, will close the subscription channel and remove it from the list of subscriptions.
type Option ¶
type Option func(*config) error
Option configures a server.
func WithConnectionOpener ¶
WithConnectionOpener configures the opener to use to create a new connection.
func WithConnectionOptions ¶
WithConnectionOptions configures server's connections. The options provided overwrite all previously configured options.
func WithHeartbeatInterval ¶
WithHeartbeatInterval configures a server's heartbeat interval. This option will be ignored when creating a Server with a pre-existing monitor.
func WithHeartbeatTimeout ¶
WithHeartbeatTimeout configures how long to wait for a heartbeat socket to connect.
func WithMaxConnections ¶
WithMaxConnections configures maximum number of connections to allow for a given server. If max is 0, then there is no upper limit on the number of connections.
func WithMaxIdleConnections ¶
WithMaxIdleConnections configures the maximum number of idle connections allowed for the server.
func WithMoreConnectionOptions ¶
WithMoreConnectionOptions configures server's connections with additional options. The options provided are appended to any current options and may override previously configured options.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a logical connection to a server.
func New ¶
New creates a new server. Internally, it creates a new Monitor with which to monitor the state of the server. When the Server is closed, the monitor will be stopped.
func NewWithMonitor ¶
NewWithMonitor creates a new Server from an existing monitor. When the server is closed, the monitor will not be stopped. Any unspecified options will have their default value pulled from the monitor. Any monitor specific options will be ignored.
func (*Server) Connection ¶
Connection gets a connection to the server.