mnet

package
v2.0.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	CompressWireMessage(src, dst []byte) ([]byte, error)
}

Compressor is an interface used to compress wire messages. If a Connection supports compression it should implement this interface as well. The CompressWireMessage method will be called during the execution of an operation if the wire message is allowed to be compressed.

type Connection

type Connection struct {
	ReadWriteCloser
	Describer
	Streamer
	Compressor
	Pinner
}

Connection represents a connection to a MongoDB server.

func NewConnection

func NewConnection(component interface {
	ReadWriteCloser
	Describer
}) *Connection

NewConnection creates a new Connection with the provided component. This constructor returns a component that is already a Connection to avoid mis-asserting the composite interfaces.

type Describer

type Describer interface {
	Description() description.Server
	ID() string
	ServerConnectionID() *int64
	DriverConnectionID() int64
	Address() address.Address
	Stale() bool
	OIDCTokenGenID() uint64
	SetOIDCTokenGenID(uint64)
}

Describer represents a Connection that can be described.

type Pinner

type Pinner interface {
	PinToCursor() error
	PinToTransaction() error
	UnpinFromCursor() error
	UnpinFromTransaction() error
}

Pinner represents a Connection that can be pinned by one or more cursors or transactions. Implementations of this interface should maintain the following invariants:

  1. Each Pin* call should increment the number of references for the connection.
  2. Each Unpin* call should decrement the number of references for the connection.
  3. Calls to Close() should be ignored until all resources have unpinned the connection.

type ReadWriteCloser

type ReadWriteCloser interface {
	Read(ctx context.Context) ([]byte, error)
	Write(ctx context.Context, wm []byte) error
	io.Closer
}

ReadWriteCloser represents a Connection where server operations can read from, written to, and closed.

type Streamer

type Streamer interface {
	SetStreaming(bool)
	CurrentlyStreaming() bool
	SupportsStreaming() bool
}

Streamer represents a Connection that supports streaming wire protocol messages using the moreToCome and exhaustAllowed flags.

The SetStreaming and CurrentlyStreaming functions correspond to the moreToCome flag on server responses. If a response has moreToCome set, SetStreaming(true) will be called and CurrentlyStreaming() should return true.

CanStream corresponds to the exhaustAllowed flag. The operations layer will set exhaustAllowed on outgoing wire messages to inform the server that the driver supports streaming.

Jump to

Keyboard shortcuts

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