Documentation ¶
Overview ¶
Package dbretry contains structs that implement various db interfaces as well as consume them. They allow consumers to easily try to interact with the database a configurable number of times, with configurable backoff options and metrics.
Index ¶
Constants ¶
const ( SQLQueryRetryCounter = "sql_query_retry_count" SQLQueryEndCounter = "sql_query_end_counter" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Measures ¶
func NewMeasures ¶
type Option ¶
type Option func(r *retryConfig)
Option is the function used to configure the retry object.
func WithBackoff ¶ added in v0.4.0
func WithBackoff(b backoff.ExponentialBackOff) Option
WithBackoff sets the exponential backoff to use when retrying. If this isn't called, we use the backoff package's default ExponentialBackoff configuration. If any values are considered invalid, they are replaced with those defaults.
func WithMeasures ¶
WithMeasures sets a provider to use for metrics.
type RetryInsertService ¶
type RetryInsertService struct {
// contains filtered or unexported fields
}
RetryInsertService is a wrapper for a db.Inserter. If inserting fails, the retry service will continue to try until the configurable max elapsed time is reached. The retries will exponentially backoff in the manner configured. To read more about this, see the backoff package GoDoc: https://godoc.org/gopkg.in/cenkalti/backoff.v3
func CreateRetryInsertService ¶
func CreateRetryInsertService(inserter db.Inserter, options ...Option) RetryInsertService
CreateRetryInsertService takes an inserter and the options provided and creates a RetryInsertService.
func (RetryInsertService) AddRetryMetric ¶ added in v0.4.0
func (ri RetryInsertService) AddRetryMetric(_ error, _ time.Duration)
AddRetryMetric is a function to add to our metrics when we retry. The function is passed to the backoff package and is called when we are retrying.
func (RetryInsertService) InsertRecords ¶
func (ri RetryInsertService) InsertRecords(records ...db.Record) error
InsertRecords uses the inserter to insert the records and uses the ExponentialBackoff to try again if inserting fails.