Documentation ¶
Index ¶
- Constants
- Variables
- func CloseIdleHTTPConnections(client *http.Client)
- func GetEncryptedStateCollectionName(efBSON bsoncore.Document, dataCollectionName string, stateCollection string) (string, error)
- func IsTimeoutContext(ctx context.Context) bool
- func MakeTimeoutContext(ctx context.Context, to time.Duration) (context.Context, context.CancelFunc)
- func MultiError(errors ...error) error
- func NewBackgroundContext(ctx context.Context) context.Context
- func RolledUpErrorMessage(err error) string
- func StringSliceFromRawElement(element bson.RawElement) ([]string, error)
- func StringSliceFromRawValue(name string, val bson.RawValue) ([]string, error)
- func UnwrapError(err error) error
- func WrapError(inner error, message string) error
- func WrapErrorf(inner error, format string, args ...interface{}) error
- type CancellationListener
- type WrappedError
- type ZeroRTTMonitor
Constants ¶
const ( EncryptedCacheCollection = "ecc" EncryptedStateCollection = "esc" EncryptedCompactionCollection = "ecoc" )
Variables ¶
var ( // ErrLoadBalancedWithMultipleHosts is returned when loadBalanced=true is specified in a URI with multiple hosts. ErrLoadBalancedWithMultipleHosts = errors.New("loadBalanced cannot be set to true if multiple hosts are specified") // ErrLoadBalancedWithReplicaSet is returned when loadBalanced=true is specified in a URI with the replicaSet option. ErrLoadBalancedWithReplicaSet = errors.New("loadBalanced cannot be set to true if a replica set name is specified") // ErrLoadBalancedWithDirectConnection is returned when loadBalanced=true is specified in a URI with the directConnection option. ErrLoadBalancedWithDirectConnection = errors.New("loadBalanced cannot be set to true if the direct connection option is specified") // ErrSRVMaxHostsWithReplicaSet is returned when srvMaxHosts > 0 is specified in a URI with the replicaSet option. ErrSRVMaxHostsWithReplicaSet = errors.New("srvMaxHosts cannot be a positive value if a replica set name is specified") // ErrSRVMaxHostsWithLoadBalanced is returned when srvMaxHosts > 0 is specified in a URI with loadBalanced=true. ErrSRVMaxHostsWithLoadBalanced = errors.New("srvMaxHosts cannot be a positive value if loadBalanced is set to true") )
var DefaultHTTPClient = &http.Client{ Transport: http.DefaultTransport.(*http.Transport).Clone(), }
DefaultHTTPClient is the default HTTP client used across the driver.
var LegacyHello = "isMaster"
LegacyHello is the legacy version of the hello command.
var LegacyHelloLowercase = "ismaster"
LegacyHelloLowercase is the lowercase, legacy version of the hello command.
var LegacyNotPrimary = "not master"
LegacyNotPrimary is the legacy version of the "not primary" server error message.
var Version = "local build"
Version is the current version of the driver.
Functions ¶
func CloseIdleHTTPConnections ¶
CloseIdleHTTPConnections closes any connections which were previously connected from previous requests but are now sitting idle in a "keep-alive" state. It does not interrupt any connections currently in use. Borrowed from go standard library.
func GetEncryptedStateCollectionName ¶
func GetEncryptedStateCollectionName(efBSON bsoncore.Document, dataCollectionName string, stateCollection string) (string, error)
GetEncryptedStateCollectionName returns the encrypted state collection name associated with dataCollectionName.
func IsTimeoutContext ¶
func MakeTimeoutContext ¶
func MakeTimeoutContext(ctx context.Context, to time.Duration) (context.Context, context.CancelFunc)
MakeTimeoutContext returns a new context with Client-Side Operation Timeout (CSOT) feature-gated behavior and a Timeout set to the passed in Duration. Setting a Timeout on a single operation is not supported in public API.
TODO(GODRIVER-2348) We may be able to remove this function once CSOT feature-gated behavior becomes the TODO default behavior.
func MultiError ¶
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 ¶
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 ¶
RolledUpErrorMessage gets a flattened error message.
func StringSliceFromRawElement ¶
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 ¶
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 ¶
UnwrapError attempts to unwrap the error down to its root cause.
func WrapErrorf ¶
WrapErrorf wraps an error with a message.
Types ¶
type CancellationListener ¶
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 ¶
func NewCancellationListener() *CancellationListener
NewCancellationListener constructs a CancellationListener.
func (*CancellationListener) Listen ¶
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 ¶
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 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.
type ZeroRTTMonitor ¶
type ZeroRTTMonitor struct{}
ZeroRTTMonitor implements the RTTMonitor interface and is used internally for testing. It returns 0 for all RTT calculations and an empty string for RTT statistics.
func (*ZeroRTTMonitor) EWMA ¶
func (zrm *ZeroRTTMonitor) EWMA() time.Duration
EWMA implements the RTT monitor interface.
func (*ZeroRTTMonitor) Min ¶
func (zrm *ZeroRTTMonitor) Min() time.Duration
Min implements the RTT monitor interface.
func (*ZeroRTTMonitor) P90 ¶
func (zrm *ZeroRTTMonitor) P90() time.Duration
P90 implements the RTT monitor interface.
func (*ZeroRTTMonitor) Stats ¶
func (zrm *ZeroRTTMonitor) Stats() string
Stats implements the RTT monitor interface.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
awserr
Package awserr represents API error interface accessors for the SDK.
|
Package awserr represents API error interface accessors for the SDK. |
Package randutil provides common random number utilities.
|
Package randutil provides common random number utilities. |
rand
Package rand implements pseudo-random number generators.
|
Package rand implements pseudo-random number generators. |