limiter

package
v1.8.12 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReConnectionLimitFieldName = "db.re_connection.limit"

	ReConnectionLimitDefault = uint16(10)
)

Variables

View Source
var Component = &app.Component{
	Dependencies: app.Components{
		logger.Component,
		configurator.Component,
		reConfiguration.Component,
		info.Component,
	},
	Constructor: app.Constructor(func(container container.Container) error {
		return container.Provides(
			NewConfig,
			NewReConfigurationWithConfigurator,
			func(reConfiguration *ReConfiguration) Limiter { return reConfiguration },
		)
	}),
	BindFlags: app.BindFlags(func(flagSet *pflag.FlagSet, container container.Container) error {
		return container.Invoke(func(config *Config) {
			flagSet.Uint16Var(
				&config.ReConnectionLimit,
				ReConnectionLimitFieldName,
				ReConnectionLimitDefault,
				"the maximum number of reconnection attempts, if 0 then unlimited",
			)
		})
	}),
	Run: app.Run(func(container container.Container) error {
		return container.Invoke(func(
			limiter *ReConfiguration,
			reConfiguration reConfiguration.ReConfiguration,
			informer logger.Informer,
			info info.Info,
			config *Config,
		) {
			reConfiguration.Registration(limiter)
			informer.Info("data_base.limiter: registration in the reConfigurator")

			info.Registration("data_base.limiter", config)
		})
	}),
}

Functions

This section is empty.

Types

type Config

type Config struct {
	ReConnectionLimit uint16
}

func Configuration

func Configuration(config *Config, configurator configurator.Configurator) *Config

func NewConfig

func NewConfig() *Config

type Limit

type Limit struct {
	// contains filtered or unexported fields
}

func NewLimit

func NewLimit(config *Config) *Limit

func (*Limit) Next

func (limier *Limit) Next() bool

func (*Limit) Reset

func (limier *Limit) Reset()

type Limiter

type Limiter interface {
	Next() bool
	Reset()
}

func New

func New(config *Config) Limiter

type ReConfiguration

type ReConfiguration struct {
	// contains filtered or unexported fields
}

func NewReConfiguration

func NewReConfiguration(logger logger.Logger, config *Config) *ReConfiguration

func NewReConfigurationWithConfigurator

func NewReConfigurationWithConfigurator(logger logger.Logger, config *Config, configurator configurator.Configurator) *ReConfiguration

func (*ReConfiguration) Limiter

func (reConfiguration *ReConfiguration) Limiter() Limiter

func (*ReConfiguration) Next

func (reConfiguration *ReConfiguration) Next() bool

func (*ReConfiguration) ReConfiguration

func (reConfiguration *ReConfiguration) ReConfiguration(configurator configurator.Configurator) error

func (*ReConfiguration) Reset

func (reConfiguration *ReConfiguration) Reset()

type UnLimit

type UnLimit struct{}

func NewUnLimit

func NewUnLimit() *UnLimit

func (*UnLimit) Next

func (limiter *UnLimit) Next() bool

func (*UnLimit) Reset

func (limiter *UnLimit) Reset()

Jump to

Keyboard shortcuts

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