backoff

package
v1.7.14 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package backoff provides backoff function controller

Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>

Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package backoff provides backoff function controller

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBackoffName added in v1.5.4

func FromBackoffName(ctx context.Context) string

FromBackoffName returns the value associated with this context for key (backoffNameContextKey).

func Metrics added in v1.5.4

func Metrics(context.Context) map[string]int64

func WithBackoffName added in v1.5.4

func WithBackoffName(ctx context.Context, name string) context.Context

WithBackoffName returns a copy of parent in which the method associated with key (backoffNameContextKey).

Types

type Backoff

type Backoff interface {
	Do(context.Context, func(ctx context.Context) (any, bool, error)) (any, error)
	Close()
}

Backoff represents an interface to handle backoff operation.

func New

func New(opts ...Option) Backoff

New creates the new backoff with option.

type Option

type Option func(*backoff)

Option represents the functional option for backoff.

func WithBackOffFactor

func WithBackOffFactor(f float64) Option

WithBackOffFactor returns the option to set the factor of backoff.

func WithBackOffTimeLimit

func WithBackOffTimeLimit(dur string) Option

WithBackOffTimeLimit returns the option to set the limit of backoff.

func WithDisableErrorLog

func WithDisableErrorLog() Option

WithDisableErrorLog returns the option to set the disable for error log.

func WithEnableErrorLog

func WithEnableErrorLog() Option

WithEnableErrorLog returns the option to set the enable for error log.

func WithInitialDuration

func WithInitialDuration(dur string) Option

WithInitialDuration returns the option to set the initial duration of backoff.

func WithJitterLimit

func WithJitterLimit(dur string) Option

WithJitterLimit returns the option to set the jitter limit duration of backoff.

func WithMaximumDuration

func WithMaximumDuration(dur string) Option

WithMaximumDuration returns the option to set the maximum duration of backoff.

func WithRetryCount

func WithRetryCount(c int) Option

WithRetryCount returns the option to set the retry count of backoff.

Jump to

Keyboard shortcuts

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