driver

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package driver provides low-level wire protocol driver for testing.

Index

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 connection.

It is not safe for concurrent use.

Logger is used only with debug level.

func Connect

func Connect(ctx context.Context, uri string, l *slog.Logger) (*Conn, error)

Connect creates a new connection for the given MongoDB URI and logger.

Context can be used to cancel the connection attempt. Canceling the context after the connection is established has no effect.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) Read

func (c *Conn) Read() (*wire.MsgHeader, wire.MsgBody, error)

Read reads the next message from the connection.

func (*Conn) Request

func (c *Conn) Request(ctx context.Context, header *wire.MsgHeader, body wire.MsgBody) (*wire.MsgHeader, wire.MsgBody, error)

Request sends the given request to the connection and returns the response.

func (*Conn) Write

func (c *Conn) Write(header *wire.MsgHeader, body wire.MsgBody) error

Write writes the given message to the connection.

func (*Conn) WriteRaw

func (c *Conn) WriteRaw(b []byte) error

WriteRaw writes the given raw bytes to the connection.

Jump to

Keyboard shortcuts

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