Documentation ¶
Index ¶
- func IsTimeoutContext(ctx context.Context) bool
- func WithServerSelectionTimeout(parent context.Context, serverSelectionTimeout time.Duration) (context.Context, context.CancelFunc)
- func WithTimeout(parent context.Context, timeout *time.Duration) (context.Context, context.CancelFunc)
- type ZeroRTTMonitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTimeoutContext ¶
IsTimeoutContext checks if the provided context has been assigned a deadline or has unlimited retries.
func WithServerSelectionTimeout ¶
func WithServerSelectionTimeout( parent context.Context, serverSelectionTimeout time.Duration, ) (context.Context, context.CancelFunc)
WithServerSelectionTimeout creates a context with a timeout that is the minimum of serverSelectionTimeoutMS and context deadline. The usage of non-positive values for serverSelectionTimeoutMS are an anti-pattern and are not considered in this calculation.
func WithTimeout ¶
func WithTimeout(parent context.Context, timeout *time.Duration) (context.Context, context.CancelFunc)
WithTimeout will set the given timeout on the context, if no deadline has already been set.
This function assumes that the timeout field is static, given that the timeout should be sourced from the client. Therefore, once a timeout function parameter has been applied to the context, it will remain for the lifetime of the context.
Types ¶
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.