Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Failer ¶
type Failer struct {
Getter Getter // Getter's Get method is invoked when the Failer instance doesn't fail.
Frequency float64 // Frequency specifies how often a failure should occur. Set to 0.0 to never fail and 1.0 to always fail.
}
Failer is used for testing by causing periodic Get failures.
WARNING: Don't use this in production code.
type Getter ¶
Getter is the interface implemented by an object that provides a Get method identical to http.Client's method, to allow composition of functionality.
func NewRoundRobin ¶
NewRoundRobin returns a Getter that sends successive queries to all the Getters its list.
type Prefixer ¶
type Prefixer struct {
// The object whose Get method is invoked to get results for a query.
Getter Getter
// Prefix for each query, commonly the hostname.
Prefix string
}
Prefixer prepends the specified prefix to the URL before redirecting to the underlying Getter.
type Retrier ¶
type Retrier struct {
// Getter is the object whose Get method is invoked to Get the results for a query.
Getter Getter
// RetryCount is number of query retries to be issued if query returns error. Leave 0 to
// never retry query errors. But if you don't want to retry errors, It's best not to use a
// Retrier...
RetryCount int
// RetryCallback is predicate function that tests whether query should be retried for a
// given error. Leave nil to retry all errors.
RetryCallback func(error) bool
// RetryPause is the amount of time to wait before retrying the query with the underlying
// Getter.
RetryPause time.Duration
}
Retrier will optionally retry queries that fail.
WARNING: Retrier *should* wrap RoundRobin. That way retries don't go to the same dead server over and over.
Click to show internal directories.
Click to hide internal directories.