Documentation ¶
Index ¶
- Variables
- func PromHandler(c *gin.Context)
- func SentinelMiddleware(opts ...Option) gin.HandlerFunc
- type Authorized
- type Awarent
- func (a *Awarent) ConfigOnChange(configID string, callback func(data string)) error
- func (a *Awarent) Deregister() (bool, error)
- func (a *Awarent) GetConfig(configID string) (string, error)
- func (a *Awarent) GetService(serviceName string, group string) (model.Service, error)
- func (a *Awarent) IPFilter() gin.HandlerFunc
- func (a *Awarent) Metrics() gin.HandlerFunc
- func (a *Awarent) PublishConfig(configID, content string) (bool, error)
- func (a *Awarent) Register() (bool, error)
- func (a *Awarent) Sentinel() gin.HandlerFunc
- func (a *Awarent) ServiceClient(serviceName string, group string) (*http.Client, error)
- func (a *Awarent) Subscribe() error
- type Awarenter
- type Config
- type ConfigChangeCallback
- type Filter
- type FilterOptions
- type FlowControlOption
- type Nacos
- type Option
- type Rule
Constants ¶
This section is empty.
Variables ¶
var SMap *summaryMap
Functions ¶
func PromHandler ¶
PromHandler wrappers the standard http.Handler to gin.HandlerFunc
func SentinelMiddleware ¶
func SentinelMiddleware(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) GetService ¶ added in v1.0.1
GetService get single random service
func (*Awarent) IPFilter ¶
func (a *Awarent) IPFilter() gin.HandlerFunc
IPFilter ip filter with options
func (*Awarent) Metrics ¶
func (a *Awarent) Metrics() gin.HandlerFunc
Metrics wrappers the standard http.Handler to gin.HandlerFunc
func (*Awarent) PublishConfig ¶ added in v1.0.4
Publish the configuration to the nacos with config dataid
func (*Awarent) Sentinel ¶
func (a *Awarent) Sentinel() gin.HandlerFunc
Sentinel awarent gin use middleware
func (*Awarent) ServiceClient ¶ added in v1.0.1
ServiceClient return a httpclient for service. the httpclient auto balancer with roundrobin
type Awarenter ¶
type Awarenter interface { //Register register service Register() (bool, error) //Deregister unregister service Deregister() (bool, error) //GetConfig get config with configid from nacos GetConfig(configID string) (string, error) //ConfigOnChange listen on config change with callback function ConfigOnChange(configID string, callback ConfigChangeCallback) error ServiceClient(serviceName string, group string) (http.Client, error) GetService(serviceName string, group string) (model.Service, error) PublishConfig(configID, content string) (bool, 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 ConfigChangeCallback ¶
type ConfigChangeCallback func(data string)
ConfigChangeCallback callback function when config changed
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 FlowControlOption struct { Resource string `yaml:"resource"` Threshold float64 `yaml:"threshold"` QueriesPerDay float64 `yaml:"queriesPerDay"` QueryBlock bool `yaml:"queryBlock"` }
FlowControlOption option for flow control resource for specify resource need to be controled, threshold, means every second passed request by flowcontrol. here means QPS
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 WithBlockExtractor ¶ added in v1.0.5
func WithBlockFallback ¶
WithBlockFallback sets the fallback handler when requests are blocked.
func WithParamExtractor ¶ added in v1.0.5
type Rule ¶
type Rule struct { ResourceParam string `yaml:"resource-param"` FlowControlRules []FlowControlOption `yaml:"flow-control-rules"` IPFilterRules FilterOptions `yaml:"ip-filter-rules"` }
Rule struct for flowcontrol/ipfilter rule collection.