wcwrapper

package
v0.0.0-...-9cd3c4a Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package wcwrapper exists so that we can wrap the Go driver's writeconcern.WriteConcern type to provide a WriteConcern with a timeout. See the documentation for the WriteConcern type for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WriteConcern

type WriteConcern struct {
	*writeconcern.WriteConcern
	WTimeout time.Duration
}

WriteConcern wraps the Go driver's standard WriteConcern type and adds a WTimeout field. This was added when we upgraded the Go driver to v2, which removed the WTimeout field from its writeconcern with the guidance to use contexts instead. This type exists so that we can do that relatively easily by stashing a provided WTimeout value along with the ordinary write concern. The tools can take a --writeConcern flag that contains a JSON string that might include wtimeout, so by using this wrapper type we can create a context with the correct timeout to match. (The alternative would be to pass a WTimeout value around separately, but we only need that value where we already need the ordinary WriteConcern anwyay.)

func Majority

func Majority() *WriteConcern

Majority is a convenience function that returns a wrapped majority write concern.

func New

func New() *WriteConcern

New returns an empty WriteConcern.

func Wrap

Wrap returns a WriteConcern that wraps the provided driver-standard writeconcern.WriteConcern.

func (*WriteConcern) MarshalBSON

func (wc *WriteConcern) MarshalBSON() ([]byte, error)

MarshalBSON implements the bson.Marshaler interface.

Jump to

Keyboard shortcuts

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