plugins

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultLocalize

func GetDefaultLocalize() (*i18n.Localizer, error)

func GetLocalize

func GetLocalize(lang string) (*i18n.Localizer, error)

Types

type Fuse

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

Fuse @Plugin 熔断

func NewFuse

func NewFuse() *Fuse

func (*Fuse) Enabler

func (this *Fuse) Enabler() bool

func (*Fuse) InitModule

func (this *Fuse) InitModule()

type FuseConfig

type FuseConfig struct {
	FuseOpt FuseOpt `mapstructure:"fuse"`
}

func (*FuseConfig) InitDefaultConfig

func (this *FuseConfig) InitDefaultConfig(vp *viper.Viper)

type FuseOpt

type FuseOpt struct {
	Enable bool
	Rules  map[string]*FuseRuleOpt `mapstructure:"fuseRules"`
}

type FuseRuleOpt

type FuseRuleOpt struct {
	// 定义执行command的超时时间(ms)
	Timeout int `mapstructure:"timeout"`
	// 定义command的最大并发量
	MaxConcurrentRequests int `mapstructure:"maxConcurrentRequests"`
	// 在熔断器被打开后,根据SleepWindow设置的时间控制多久后尝试服务是否可用
	SleepWindow int `mapstructure:"sleepWindow"`
	// 判断熔断开关的条件之一,统计10s内请求数量,达到这个请求数量后再根据错误率判断是否要开启熔断
	RequestVolumeThreshold int `mapstructure:"requestVolumeThreshold"`
	// 判断熔断开关的条件之一,错误率到达这个百分比后就会启动熔断
	ErrorPercentThreshold int `mapstructure:"errorPercentThreshold"`
}

FuseRuleOpt 熔断器配置

type I18n

type I18n struct {
	Localize map[string]*i18n.Localizer
	Bundle   *i18n.Bundle
	// contains filtered or unexported fields
}

I18n @Plugin 国际化

func NewI18n

func NewI18n() *I18n

func (*I18n) Enabler

func (this *I18n) Enabler() bool

func (*I18n) InitModule

func (this *I18n) InitModule()

type I18nConfig

type I18nConfig struct {
	I18nOpt I18nOpt `mapstructure:"i18n"`
}

I18nConfig 限流规则map

func (*I18nConfig) InitDefaultConfig

func (this *I18nConfig) InitDefaultConfig(vp *viper.Viper)

type I18nOpt

type I18nOpt struct {
	Enable          bool
	DefaultLanguage string `mapstructure:"defaultLanguage"` // 默认语言(如:zh en ja)
}

I18nOpt 国际化配置

Jump to

Keyboard shortcuts

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