limiter

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 7 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,
		re_configuration.Component,
	},
	Constructor: func(container container.Container) error {
		return container.Provides(
			NewConfig,
			NewReConfigurationWithConfigurator,
			func(reConfiguration *ReConfiguration) Limiter { return reConfiguration },
		)
	},
	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: func(c container.Container) error {
		limiter, err := container.Get[*ReConfiguration](c)
		if err != nil {
			return err
		}

		reConfiguration, err := container.Get[configurator.ReConfiguration](c)
		if err != nil {
			return err
		}

		informer, err := container.Get[logger.Informer](c)
		if err != nil {
			return err
		}

		reConfiguration.Registration(limiter)
		informer.Info("data_base.re_connection.limiter: registration in the reConfigurator")

		return nil
	},
}

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