Home / File/ config.go — fiber Source File

config.go — fiber Source File

Architecture documentation for config.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Context 1 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  375cf52c_a275_c066_8b6b_9b79f51587e5["config.go"]
  d31b53b2_3d0c_f538_f920_e1ae643c437c["time"]
  375cf52c_a275_c066_8b6b_9b79f51587e5 --> d31b53b2_3d0c_f538_f920_e1ae643c437c
  style 375cf52c_a275_c066_8b6b_9b79f51587e5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package retry

import (
	"time"
)

// Config defines the config for addon.
type Config struct {
	// InitialInterval defines the initial time interval for backoff algorithm.
	//
	// Optional. Default: 1 * time.Second
	InitialInterval time.Duration

	// MaxBackoffTime defines maximum time duration for backoff algorithm. When
	// the algorithm is reached this time, rest of the retries will be maximum
	// 32 seconds.
	//
	// Optional. Default: 32 * time.Second
	MaxBackoffTime time.Duration

	// Multiplier defines multiplier number of the backoff algorithm.
	//
	// Optional. Default: 2.0
	Multiplier float64

	// MaxRetryCount defines maximum retry count for the backoff algorithm.
	//
	// Optional. Default: 10
	MaxRetryCount int

	// currentInterval tracks the current waiting time.
	//
	// Optional. Default: 1 * time.Second
	currentInterval time.Duration
}

// DefaultConfig is the default config for retry.
var DefaultConfig = Config{
	InitialInterval: 1 * time.Second,
	MaxBackoffTime:  32 * time.Second,
	Multiplier:      2.0,
	MaxRetryCount:   10,
	currentInterval: 1 * time.Second,
}

// configDefault sets the config values if they are not set.
func configDefault(config ...Config) Config {
	if len(config) == 0 {
		return DefaultConfig
	}
	cfg := config[0]
	if cfg.InitialInterval == 0 {
		cfg.InitialInterval = DefaultConfig.InitialInterval
	}
	if cfg.MaxBackoffTime == 0 {
		cfg.MaxBackoffTime = DefaultConfig.MaxBackoffTime
	}
	if cfg.Multiplier <= 0 {
		cfg.Multiplier = DefaultConfig.Multiplier
	}
	if cfg.MaxRetryCount <= 0 {
		cfg.MaxRetryCount = DefaultConfig.MaxRetryCount
	}
	if cfg.currentInterval == 0 {
		cfg.currentInterval = cfg.InitialInterval
	}
	return cfg
}

Domain

Subdomains

Functions

Classes

Dependencies

  • time

Frequently Asked Questions

What does config.go do?
config.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Context subdomain.
What functions are defined in config.go?
config.go defines 1 function(s): configDefault.
What does config.go depend on?
config.go imports 1 module(s): time.
Where is config.go in the architecture?
config.go is located at addon/retry/config.go (domain: FiberCore, subdomain: Context, directory: addon/retry).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free