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 Wrap ¶
func Wrap(base *writeconcern.WriteConcern) *WriteConcern
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.