Documentation ¶
Index ¶
- func PromHandler(c *gin.Context)
- func SentinelMiddleware(endPoint string, opts ...Option) gin.HandlerFunc
- type Authorized
- type Awarent
- func (a *Awarent) ConfigOnChange(configID string) error
- func (a *Awarent) Deregister() (bool, error)
- func (a *Awarent) GetConfig(configID string) (string, error)
- func (a *Awarent) IPFilter() gin.HandlerFunc
- func (a *Awarent) LoadRules(rules ...FlowControlOption) (bool, error)
- func (a *Awarent) Metrics() gin.HandlerFunc
- func (a *Awarent) Register() (bool, error)
- func (a *Awarent) Sentinel() gin.HandlerFunc
- func (a *Awarent) Subscribe() error
- type Awarenter
- type Config
- type Filter
- type FilterOptions
- type FlowControlOption
- type Nacos
- type Option
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PromHandler ¶
PromHandler wrappers the standard http.Handler to gin.HandlerFunc
func SentinelMiddleware ¶
func SentinelMiddleware(endPoint string, opts ...Option) gin.HandlerFunc
SentinelMiddleware returns new gin.HandlerFunc Default resource name is {method}:{path}, such as "GET:/api/users/:id" Default block fallback is returning 429 code Define your own behavior by setting options
Types ¶
type Authorized ¶
type Awarent ¶
type Awarent struct {
// contains filtered or unexported fields
}
Awarent struct of awarent
func InitAwarent ¶
InitAwarent init awarent module
func (*Awarent) ConfigOnChange ¶
ConfigOnChange listen on config change.
func (*Awarent) Deregister ¶
Deregister deregister service
func (*Awarent) IPFilter ¶
func (a *Awarent) IPFilter() gin.HandlerFunc
IPFilter ip filter with options
func (*Awarent) LoadRules ¶
func (a *Awarent) LoadRules(rules ...FlowControlOption) (bool, error)
LoadRules load flow control rules
func (*Awarent) Metrics ¶
func (a *Awarent) Metrics() gin.HandlerFunc
Metrics wrappers the standard http.Handler to gin.HandlerFunc
func (*Awarent) Sentinel ¶
func (a *Awarent) Sentinel() gin.HandlerFunc
Sentinel awarent gin use middleware
type Awarenter ¶
type Awarenter interface { Register() (bool, error) Deregister() (bool, error) GetConfig(configID string) (string, error) ConfigOnChange(configID string) error }
Awarenter interface of awarent
type Config ¶
type Config struct { ServiceName string `yaml:"serviceName" toml:"serviceName" json:"serviceName"` Port uint64 `yaml:"port" toml:"port" json:"port"` Group string `yaml:"group" toml:"group" json:"group"` Nacos Nacos `yaml:"nacos" toml:"nacos" json:"nacos"` ConfigID string `yaml:"configId" toml:"configId" json:"configId"` RuleID string `yaml:"ruleId" toml:"ruleId" json:"ruleId"` }
Config warentConfig entry struct
type FilterOptions ¶
type FilterOptions struct { //explicity allowed IPs AllowedIPs []string `yaml:"allowed"` BlockedIPs []string `yaml:"blocked"` URLPath string `yaml:"urlPath"` URLParam string `yaml:"urlParam"` AuthorizedIPs []Authorized `yaml:"authorized"` BlockByDefault bool `yaml:"blockedDefault"` }
FilterOptions for IPFilter. Allow/Block setting
type FlowControlOption ¶
type Nacos ¶
type Nacos struct { IP string `yaml:"ip" toml:"ip" json:"ip"` Port uint64 `yaml:"port" toml:"port" json:"port"` }
Nacos config
type Option ¶
type Option func(*options)
Option func with options param
func WithBlockFallback ¶
WithBlockFallback sets the fallback handler when requests are blocked.
type Rule ¶
type Rule struct { ResourceParam string `yaml:"resource-param"` FlowControlRules []FlowControlOption `yaml:"flow-control-rules"` IPFilterRules FilterOptions `yaml:"ip-filter-rules"` }