Documentation ¶
Overview ¶
Package backoff provides backoff function controller
Copyright (C) 2019-2023 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 ¶
- func FromBackoffName(ctx context.Context) string
- func Metrics(context.Context) map[string]int64
- func WithBackoffName(ctx context.Context, name string) context.Context
- type Backoff
- type Option
- func WithBackOffFactor(f float64) Option
- func WithBackOffTimeLimit(dur string) Option
- func WithDisableErrorLog() Option
- func WithEnableErrorLog() Option
- func WithInitialDuration(dur string) Option
- func WithJitterLimit(dur string) Option
- func WithMaximumDuration(dur string) Option
- func WithRetryCount(c int) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromBackoffName ¶ added in v1.5.4
FromBackoffName returns the value associated with this context for key (backoffNameContextKey).
Types ¶
type Backoff ¶
type Backoff interface { Do(context.Context, func(ctx context.Context) (interface{}, bool, error)) (interface{}, error) Close() }
Backoff represents an interface to handle backoff operation.
type Option ¶
type Option func(*backoff)
Option represents the functional option for backoff.
func WithBackOffFactor ¶
WithBackOffFactor returns the option to set the factor of backoff.
func WithBackOffTimeLimit ¶
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 ¶
WithInitialDuration returns the option to set the initial duration of backoff.
func WithJitterLimit ¶
WithJitterLimit returns the option to set the jitter limit duration of backoff.
func WithMaximumDuration ¶
WithMaximumDuration returns the option to set the maximum duration of backoff.
func WithRetryCount ¶
WithRetryCount returns the option to set the retry count of backoff.