clientinfra

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package clientinfra provides shared Mongo client setup helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureIndexes

func EnsureIndexes(timeout time.Duration, ensure func(context.Context) error) error

EnsureIndexes runs index initialization with a timeout-bounded background context.

func Ping

func Ping(ctx context.Context, client *mongodriver.Client, normalizeNil bool) error

Ping performs the common primary-read-preference health check.

func ResolveTimeout

func ResolveTimeout(timeout time.Duration, defaultTimeout time.Duration) time.Duration

ResolveTimeout applies the package default when the configured timeout is not positive.

func ValidateMongoOptions

func ValidateMongoOptions(client *mongodriver.Client, database string) error

ValidateMongoOptions checks the shared required Mongo constructor inputs.

func WithTimeout

func WithTimeout(ctx context.Context, timeout time.Duration, normalizeNil bool) (context.Context, context.CancelFunc)

WithTimeout wraps the caller context with the configured timeout.

Types

type Cursor added in v1.1.0

type Cursor struct {
	Cur *mongodriver.Cursor
}

Cursor adapts mongodriver.Cursor to a feature-local interface.

func (Cursor) Close added in v1.1.0

func (c Cursor) Close(ctx context.Context) error

Close forwards to the wrapped Cursor.

func (Cursor) Decode added in v1.1.0

func (c Cursor) Decode(val any) error

Decode forwards to the wrapped Cursor.

func (Cursor) Err added in v1.1.0

func (c Cursor) Err() error

Err forwards to the wrapped Cursor.

func (Cursor) Next added in v1.1.0

func (c Cursor) Next(ctx context.Context) bool

Next forwards to the wrapped Cursor.

type IndexView added in v1.1.0

type IndexView struct {
	View mongodriver.IndexView
}

IndexView adapts mongodriver.IndexView to a feature-local interface.

func (IndexView) CreateOne added in v1.1.0

CreateOne forwards to the wrapped IndexView.

type SingleResult added in v1.1.0

type SingleResult struct {
	Res *mongodriver.SingleResult
}

SingleResult adapts mongodriver.SingleResult to a feature-local interface.

func (SingleResult) Decode added in v1.1.0

func (r SingleResult) Decode(val any) error

Decode forwards to the wrapped SingleResult.

Jump to

Keyboard shortcuts

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