func GetCommandFromMsgWireMessage(wm []byte) (bsoncore.Document, error)
GetCommandFromMsgWireMessage returns the command document sent in an OP_MSG wire message.
func GetCommandFromQueryWireMessage(wm []byte) (bsoncore.Document, error)
GetCommandFromQueryWireMessage returns the command sent in an OP_QUERY wire message.
func MakeReply(doc bsoncore.Document) []byte
MakeReply creates an OP_REPLY wiremessage from a BSON document
ChannelConn implements the driver.Connection interface by reading and writing wire messages to a channel
type ChannelConn struct { WriteErr error Written chan []byte ReadResp chan []byte ReadErr chan error Desc description.Server }
func (c *ChannelConn) Address() address.Address
Address implements the driver.Connection interface.
func (c *ChannelConn) Close() error
Close implements the driver.Connection interface.
func (c *ChannelConn) Description() description.Server
Description implements the driver.Connection interface.
func (c *ChannelConn) DriverConnectionID() uint64
DriverConnectionID implements the driver.Connection interface. TODO(GODRIVER-2824): replace return type with int64.
func (c *ChannelConn) ID() string
ID implements the driver.Connection interface.
func (c *ChannelConn) ReadWireMessage(ctx context.Context) ([]byte, error)
ReadWireMessage implements the driver.Connection interface.
func (c *ChannelConn) ServerConnectionID() *int64
ServerConnectionID implements the driver.Connection interface.
func (c *ChannelConn) Stale() bool
Stale implements the driver.Connection interface.
func (c *ChannelConn) WriteWireMessage(ctx context.Context, wm []byte) error
WriteWireMessage implements the driver.Connection interface.
ChannelNetConn implements the net.Conn interface by reading and writing wire messages to a channel.
type ChannelNetConn struct { WriteErr error Written chan []byte ReadResp chan []byte ReadErr chan error }
func (c *ChannelNetConn) AddResponse(resp []byte) error
AddResponse adds a response to the connection.
func (c *ChannelNetConn) Close() error
Close closes the connection.
func (c *ChannelNetConn) GetWrittenMessage() []byte
GetWrittenMessage gets the last wire message written to the connection
func (c *ChannelNetConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (c *ChannelNetConn) Read(b []byte) (int, error)
Read reads data from the connection
func (c *ChannelNetConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.
func (c *ChannelNetConn) SetDeadline(_ time.Time) error
SetDeadline sets the read and write deadlines associated with the connection.
func (c *ChannelNetConn) SetReadDeadline(_ time.Time) error
SetReadDeadline sets the read and write deadlines associated with the connection.
func (c *ChannelNetConn) SetWriteDeadline(_ time.Time) error
SetWriteDeadline sets the read and write deadlines associated with the connection.
func (c *ChannelNetConn) Write(b []byte) (int, error)
Write writes data to the connection.