mongoutil

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthFromURI

func AuthFromURI(uri string) (*options.Credential, error)

AuthFromURI will create a Credentials object given the provided URI.

func HostsFromURI

func HostsFromURI(uri string) ([]string, error)

HostsFromURI will parse the hosts in the URI and return them as a slice of strings.

func NewOptions

func NewOptions[T any](opts ...options.Lister[T]) (*T, error)

NewOptions will functionally merge a slice of mongo.Options in a "last-one-wins" manner, where nil options are ignored.

func TimeoutWithinContext added in v2.3.0

func TimeoutWithinContext(ctx context.Context, timeout time.Duration) bool

TimeoutWithinContext will return true if the provided timeout is nil or if it is less than the context deadline. If the context does not have a deadline, it will return true.

Types

type OptionsLister

type OptionsLister[T any] struct {
	Options  *T             // Arguments to set on the option type
	Callback func(*T) error // A callback for further modification
}

OptionsLister implements an options.SetterLister object for an arbitrary options type.

func NewOptionsLister

func NewOptionsLister[T any](args *T, callback func(*T) error) *OptionsLister[T]

NewOptionsLister will construct a SetterLister from the provided Options object.

func (*OptionsLister[T]) List

func (opts *OptionsLister[T]) List() []func(*T) error

List will re-assign the entire argument option to the Args field defined on opts. If a callback exists, that function will be executed to further modify the arguments.

Jump to

Keyboard shortcuts

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