Documentation ¶
Overview ¶
Package wireclient provides low-level wire protocol client.
Index ¶
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) Login(ctx context.Context, username, password, authDB string) error
- func (c *Conn) Ping(ctx context.Context) error
- func (c *Conn) Read(ctx context.Context) (*wire.MsgHeader, wire.MsgBody, error)
- func (c *Conn) Request(ctx context.Context, body wire.MsgBody) (*wire.MsgHeader, wire.MsgBody, error)
- func (c *Conn) Write(ctx context.Context, header *wire.MsgHeader, body wire.MsgBody) error
- func (c *Conn) WriteRaw(ctx context.Context, b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a single client connection.
It is not safe for concurrent use.
func Connect ¶
Connect creates a new connection for the given MongoDB URI.
Context can be used to cancel the connection attempt. Canceling the context after the connection is established has no effect.
The passed logger will be used only for debug-level messages.
func ConnectPing ¶ added in v0.0.6
ConnectPing uses a combination of Connect and Conn.Ping to establish a working connection.
nil is returned on context expiration.
func New ¶
New wraps the given connection.
The passed logger will be used only for debug-level messages.
func (*Conn) Login ¶ added in v0.0.6
Login authenticates the connection with the given credentials using some unspecified sequences of commands.
It should not be used to test various authentication scenarios.
func (*Conn) Ping ¶ added in v0.0.6
Ping sends a ping command. It returns error for unexpected server response or any other error.
func (*Conn) Read ¶
Read reads the next message from the connection.
Passed context's deadline is honored if set.
func (*Conn) Request ¶
func (c *Conn) Request(ctx context.Context, body wire.MsgBody) (*wire.MsgHeader, wire.MsgBody, error)
Request sends the given request to the connection and returns the response. The header is generated automatically.
Passed context's deadline is honored if set.
It returns errors only for request/response parsing or connection issues. All protocol-level errors are stored inside response.