dial

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dial provides the actual dialing features used by the untilMongod command.

It might conceivably be imported on its own for other use case, since it does not have any dependency on the command itself.

• dial.go contains its dialing-related parts

• time.go file contains its time-related parts

Index

Constants

View Source
const BackoffFactor = 1.5

BackoffFactor is the interval increase coefficient for retries.

View Source
const DefaultURL = "mongodb://localhost:27017"

DefaultURL is the default MongoDB server URL.

View Source
const ExpectedErrorString = "no reachable servers"

ExpectedErrorString is used by MongoDB clients to signal it could not connect, starting with the mongo shell.

View Source
const MaxDuration time.Duration = 1<<63 - 1

MaxDuration is the largest Duration the time.Duration type can represent.

Cannot use time.maxDuration since it is private in time package.

Variables

This section is empty.

Functions

func IsMaxTimeoutValid

func IsMaxTimeoutValid(t time.Duration) bool

IsMaxTimeoutValid ensures timeouts passed to dialers are positive and not too large.

Types

type DriverDial

type DriverDial = func(url string, duration time.Duration) error

DriverDial is the type of the lower-level functions actually implementing the "connect to a server" feature, without the backoff mechanism.

Its implementations are typically thin wrappers around a driver-provided mechanism.

func NewMongoDbDial

func NewMongoDbDial() DriverDial

NewMongoDbDial returns a new DriverDial function using the official MongoDB driver available at https://github.com/mongodb/mongo-go-driver

type Reporter

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

Reporter prints to a writer, defaulting to stderr, only if verbose is true.

func NewReporter

func NewReporter(verbose bool, w ...io.Writer) Reporter

NewReporter creates an instance of Reporter.

The final variadic io.Writer argument allows passing ONE specific writer, and defaulting to os.Stderr when none is passed.

func (Reporter) Printf

func (r Reporter) Printf(format string, v ...interface{})

Printf only prints if r.verbose is true.

type Result

type Result int

Result is the type of the Dial() results.

const (
	Success Result = iota
	Timeout
	OtherError
)

These constants represent the result of Dial().

func Dial

func Dial(url string, maxTimeout time.Duration, dialer DriverDial, r Reporter) Result

Dial attempts to connect to the specified server for the specified duration, using the specified connection method.

It returns a status code usable with os.Exit().

Jump to

Keyboard shortcuts

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