documentdb

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package documentdb provides DocumentDB extension integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(ctx context.Context, conn *pgx.Conn, l *slog.Logger, docV wirebson.AnyDocument) (wirebson.RawDocument, error)

CreateUser creates a new user. Users with the `clusterAdmin` role are given PostgreSQL's SUPERUSER privileges.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn represents a pooled PostgreSQL connection. It wraps *pgxpool.Conn with resource tracking.

func (*Conn) Conn

func (conn *Conn) Conn() *pgx.Conn

Conn returns the underlying *pgx.Conn. It should not be retained by the caller.

func (*Conn) Release

func (conn *Conn) Release()

Release returns connection back to the pool, unless it was persisted/hijacked. It is safe to call this method multiple times.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represent a pool of PostgreSQL connections.

func NewPool

func NewPool(uri string, l *slog.Logger, sp *state.Provider) (*Pool, error)

NewPool creates a new pool of PostgreSQL connections. No actual connections are established.

func (*Pool) Acquire

func (p *Pool) Acquire() (*Conn, error)

Acquire acquires a connection from the pool.

It is caller's responsibility to call Conn.Release. Most callers should use Pool.WithConn instead.

func (*Pool) Aggregate

func (p *Pool) Aggregate(ctx context.Context, db string, spec wirebson.RawDocument) (wirebson.RawDocument, int64, error)

Aggregate returns the first page of the `aggregate` cursor and the cursor ID.

func (*Pool) Close

func (p *Pool) Close()

Close closes all connections in the pool.

func (*Pool) Collect

func (p *Pool) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Pool) Describe

func (p *Pool) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Pool) Find

Find returns the first page of the `find` cursor and the cursor ID.

func (*Pool) GetMore

func (p *Pool) GetMore(ctx context.Context, db string, spec wirebson.RawDocument, cursorID int64) (wirebson.RawDocument, error)

GetMore returns the next page of the cursor. It is a part of the implementation of the `getMore` command.

func (*Pool) KillCursor

func (p *Pool) KillCursor(ctx context.Context, id int64) bool

KillCursor closes the cursor with the given id and removes it from the registry. It returns true if the cursor was found and removed. It is a part of the implementation of the `killCursors` command.

It attempts a clean close by sending the exit message to PostgreSQL. However, this could block so ctx is available to limit the time to wait (up to 3 seconds). The underlying connection will always be called regardless of any other errors.

func (*Pool) ListCollections

func (p *Pool) ListCollections(ctx context.Context, db string, spec wirebson.RawDocument) (wirebson.RawDocument, int64, error)

ListCollections returns the first page of the `listCollections` cursor and the cursor ID.

func (*Pool) ListIndexes

func (p *Pool) ListIndexes(ctx context.Context, db string, spec wirebson.RawDocument) (wirebson.RawDocument, int64, error)

ListIndexes returns the first page of the `listIndexes` cursor and the cursor ID.

func (*Pool) WithConn

func (p *Pool) WithConn(f func(*pgx.Conn) error) error

WithConn acquires a connection from the pool and calls the provided function with it. The connection is automatically released after the function returns.

Directories

Path Synopsis
Package bsonhex provides functionality to decode BSONHEX type.
Package bsonhex provides functionality to decode BSONHEX type.
Package cursor provides access to DocumentDB cursors.
Package cursor provides access to DocumentDB cursors.
Package main contains code generator for DocumentDB APIs.
Package main contains code generator for DocumentDB APIs.

Jump to

Keyboard shortcuts

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