internal

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "local build"

Version is the current version of the driver.

Functions

func MultiError

func MultiError(errors ...error) error

MultiError combines multiple errors into a single error. If there are no errors, nil is returned. If there is 1 error, it is returned. Otherwise, they are combined.

func NewBackgroundContext added in v1.5.0

func NewBackgroundContext(ctx context.Context) context.Context

NewBackgroundContext creates a new Context whose behavior matches that of context.Background(), but Value calls are forwarded to the provided ctx parameter. If ctx is nil, context.Background() is returned.

func RolledUpErrorMessage

func RolledUpErrorMessage(err error) string

RolledUpErrorMessage gets a flattened error message.

func StringSliceFromRawElement added in v1.5.0

func StringSliceFromRawElement(element bson.RawElement) ([]string, error)

StringSliceFromRawElement decodes the provided BSON element into a []string. This internally calls StringSliceFromRawValue on the element's value. The error conditions outlined in that function's documentation apply for this function as well.

func StringSliceFromRawValue added in v1.5.0

func StringSliceFromRawValue(name string, val bson.RawValue) ([]string, error)

StringSliceFromRawValue decodes the provided BSON value into a []string. This function returns an error if the value is not an array or any of the elements in the array are not strings. The name parameter is used to add context to error messages.

func UnwrapError

func UnwrapError(err error) error

UnwrapError attempts to unwrap the error down to its root cause.

func WrapError

func WrapError(inner error, message string) error

WrapError wraps an error with a message.

func WrapErrorf

func WrapErrorf(inner error, format string, args ...interface{}) error

WrapErrorf wraps an error with a message.

Types

type CancellationListener added in v1.5.0

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

CancellationListener listens for context cancellation in a loop until the context expires or the listener is aborted.

func NewCancellationListener added in v1.5.0

func NewCancellationListener() *CancellationListener

NewCancellationListener constructs a CancellationListener.

func (*CancellationListener) Listen added in v1.5.0

func (c *CancellationListener) Listen(ctx context.Context, abortFn func())

Listen blocks until the provided context is cancelled or listening is aborted via the StopListening function. If this detects that the context has been cancelled (i.e. ctx.Err() == context.Canceled), the provided callback is called to abort in-progress work. Even if the context expires, this function will block until StopListening is called.

func (*CancellationListener) StopListening added in v1.5.0

func (c *CancellationListener) StopListening() bool

StopListening stops the in-progress Listen call. This blocks if there is no in-progress Listen call. This function will return true if the provided abort callback was called when listening for cancellation on the previous context.

type Semaphore

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

Semaphore is a synchronization primitive that controls access to a common resource.

func NewSemaphore

func NewSemaphore(slots uint64) *Semaphore

NewSemaphore creates a new semaphore.

func (*Semaphore) Len

func (s *Semaphore) Len() uint64

Len gets the number of permits available.

func (*Semaphore) Release

func (s *Semaphore) Release() error

Release releases a resource back into the pool.

func (*Semaphore) Wait

func (s *Semaphore) Wait(ctx context.Context) error

Wait waits until a resource is available or until the context is done.

type WrappedError

type WrappedError interface {
	// Message gets the basic message of the error.
	Message() string
	// Inner gets the inner error if one exists.
	Inner() error
}

WrappedError represents an error that contains another error.

Directories

Path Synopsis
israce
Package israce reports if the Go race detector is enabled.
Package israce reports if the Go race detector is enabled.

Jump to

Keyboard shortcuts

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