writeconcern

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInconsistent = errors.New("a write concern cannot have both w=0 and j=true")

ErrInconsistent indicates that an inconsistent write concern was specified.

View Source
var ErrNegativeW = errors.New("write concern `w` field cannot be a negative number")

ErrNegativeW indicates that a negative integer `w` field was specified.

View Source
var ErrNegativeWTimeout = errors.New("write concern `wtimeout` field cannot be negative")

ErrNegativeWTimeout indicates that a negative WTimeout was specified.

Functions

func AckWrite added in v0.0.18

func AckWrite(wc *WriteConcern) bool

AckWrite returns true if a write concern represents an acknowledged write

func AcknowledgedElement added in v0.0.18

func AcknowledgedElement(elem bsonx.Elem) bool

AcknowledgedElement returns true if a BSON element for a write concern represents an acknowledged write concern. The element's value must be a document representing a write concern.

func AcknowledgedElementRaw added in v0.0.18

func AcknowledgedElementRaw(rawv bson.RawValue) bool

AcknowledgedElementRaw returns true if a BSON RawValue for a write concern represents an acknowledged write concern. The element's value must be a document representing a write concern.

Types

type Option

type Option func(concern *WriteConcern)

Option is an option to provide when creating a ReadConcern.

func J

func J(j bool) Option

J requests acknowledgement from MongoDB that write operations are written to the journal.

func W

func W(w int) Option

W requests acknowledgement that write operations propagate to the specified number of mongod instances.

func WMajority

func WMajority() Option

WMajority requests acknowledgement that write operations propagate to the majority of mongod instances.

func WTagSet

func WTagSet(tag string) Option

WTagSet requests acknowledgement that write operations propagate to the specified mongod instance.

func WTimeout

func WTimeout(d time.Duration) Option

WTimeout specifies specifies a time limit for the write concern.

type WriteConcern

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

WriteConcern describes the level of acknowledgement requested from MongoDB for write operations to a standalone mongod or to replica sets or to sharded clusters.

func New

func New(options ...Option) *WriteConcern

New constructs a new WriteConcern.

func (*WriteConcern) Acknowledged

func (wc *WriteConcern) Acknowledged() bool

Acknowledged indicates whether or not a write with the given write concern will be acknowledged.

func (*WriteConcern) IsValid

func (wc *WriteConcern) IsValid() bool

IsValid checks whether the write concern is invalid.

func (*WriteConcern) MarshalBSONElement

func (wc *WriteConcern) MarshalBSONElement() (bsonx.Elem, error)

MarshalBSONElement marshals the write concern into a *bsonx.Element.

Jump to

Keyboard shortcuts

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