Documentation ¶
Overview ¶
Package ext/datasource provides interfaces and helper classes of dynamic data-source.
Index ¶
- Constants
- func CircuitBreakerRuleJsonArrayParser(src []byte) (interface{}, error)
- func CircuitBreakerRulesUpdater(data interface{}) error
- func FlowRuleJsonArrayParser(src []byte) (interface{}, error)
- func FlowRulesUpdater(data interface{}) error
- func HotSpotParamRuleJsonArrayParser(src []byte) (interface{}, error)
- func HotSpotParamRulesUpdater(data interface{}) error
- func IsolationRuleJsonArrayParser(src []byte) (interface{}, error)
- func IsolationRulesUpdater(data interface{}) error
- func SystemRuleJsonArrayParser(src []byte) (interface{}, error)
- func SystemRulesUpdater(data interface{}) error
- type Base
- type Code
- type DataSource
- type DefaultPropertyHandler
- func NewCircuitBreakerRulesHandler(converter PropertyConverter) *DefaultPropertyHandler
- func NewDefaultPropertyHandler(converter PropertyConverter, updater PropertyUpdater) *DefaultPropertyHandler
- func NewIsolationRulesHandler(converter PropertyConverter) *DefaultPropertyHandler
- func NewSystemRulesHandler(converter PropertyConverter) *DefaultPropertyHandler
- type Error
- type HotspotRule
- type MockPropertyHandler
- type ParamKind
- type PropertyConverter
- type PropertyHandler
- type PropertyUpdater
- type SpecificValue
Constants ¶
const ( OK = iota ConvertSourceError = 1 UpdatePropertyError = 2 HandleSourceError = 3 )
Variables ¶
This section is empty.
Functions ¶
func CircuitBreakerRulesUpdater ¶
func CircuitBreakerRulesUpdater(data interface{}) error
CircuitBreakerRulesUpdater load the newest []cb.Rule to downstream circuit breaker component.
func FlowRuleJsonArrayParser ¶
FlowRuleJsonArrayParser provide JSON as the default serialization for list of flow.Rule
func FlowRulesUpdater ¶
func FlowRulesUpdater(data interface{}) error
FlowRulesUpdater load the newest []flow.Rule to downstream flow component.
func HotSpotParamRuleJsonArrayParser ¶
HotSpotParamRuleJsonArrayParser decodes list of param flow rules from JSON bytes.
func HotSpotParamRulesUpdater ¶
func HotSpotParamRulesUpdater(data interface{}) error
HotSpotParamRulesUpdater loads the provided hot-spot param rules to downstream rule manager.
func IsolationRuleJsonArrayParser ¶
IsolationRuleJsonArrayParser provide JSON as the default serialization for list of isolation.Rule
func IsolationRulesUpdater ¶
func IsolationRulesUpdater(data interface{}) error
IsolationRulesUpdater load the newest []isolation.Rule to downstream system component.
func SystemRuleJsonArrayParser ¶
SystemRuleJsonArrayParser provide JSON as the default serialization for list of system.Rule
func SystemRulesUpdater ¶
func SystemRulesUpdater(data interface{}) error
SystemRulesUpdater load the newest []system.Rule to downstream system component.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
func (*Base) AddPropertyHandler ¶
func (b *Base) AddPropertyHandler(h PropertyHandler)
func (*Base) RemovePropertyHandler ¶
func (b *Base) RemovePropertyHandler(h PropertyHandler)
type DataSource ¶
type DataSource interface { // Add specified property handler in current datasource AddPropertyHandler(h PropertyHandler) // Remove specified property handler in current datasource RemovePropertyHandler(h PropertyHandler) // Read original data from the data source. // return source bytes if succeed to read, if not, return error when reading ReadSource() ([]byte, error) // Initialize the datasource and load initial rules // start listener to listen on dynamic source // return error if initialize failed; // once initialized, listener should recover all panic and error. Initialize() error // Close the data source. io.Closer }
The generic interface to describe the datasource Each DataSource instance listen in one property type.
type DefaultPropertyHandler ¶
type DefaultPropertyHandler struct {
// contains filtered or unexported fields
}
DefaultPropertyHandler encapsulate the Converter and updater of property. One DefaultPropertyHandler instance is to handle one property type. DefaultPropertyHandler should check whether current property is consistent with last update property converter convert the message to the specific property updater update the specific property to downstream.
func NewCircuitBreakerRulesHandler ¶
func NewCircuitBreakerRulesHandler(converter PropertyConverter) *DefaultPropertyHandler
func NewDefaultPropertyHandler ¶
func NewDefaultPropertyHandler(converter PropertyConverter, updater PropertyUpdater) *DefaultPropertyHandler
func NewIsolationRulesHandler ¶
func NewIsolationRulesHandler(converter PropertyConverter) *DefaultPropertyHandler
func NewSystemRulesHandler ¶
func NewSystemRulesHandler(converter PropertyConverter) *DefaultPropertyHandler
func (*DefaultPropertyHandler) Handle ¶
func (h *DefaultPropertyHandler) Handle(src []byte) error
type HotspotRule ¶
type HotspotRule struct { // ID is the unique id ID string `json:"id,omitempty"` // Resource is the resource name Resource string `json:"resource"` // MetricType indicates the metric type for checking logic. // For Concurrency metric, hotspot module will check the each hot parameter's concurrency, // if concurrency exceeds the Threshold, reject the traffic directly. // For QPS metric, hotspot module will check the each hot parameter's QPS, // the ControlBehavior decides the behavior of traffic shaping controller MetricType hotspot.MetricType `json:"metricType"` // ControlBehavior indicates the traffic shaping behaviour. // ControlBehavior only takes effect when MetricType is QPS ControlBehavior hotspot.ControlBehavior `json:"controlBehavior"` // ParamIndex is the index in context arguments slice. // if ParamIndex is great than or equals to zero, ParamIndex means the <ParamIndex>-th parameter // if ParamIndex is the negative, ParamIndex means the reversed <ParamIndex>-th parameter ParamIndex int `json:"paramIndex"` // Threshold is the threshold to trigger rejection Threshold int64 `json:"threshold"` // MaxQueueingTimeMs only takes effect when ControlBehavior is Throttling and MetricType is QPS MaxQueueingTimeMs int64 `json:"maxQueueingTimeMs"` // BurstCount is the silent count // BurstCount only takes effect when ControlBehavior is Reject and MetricType is QPS BurstCount int64 `json:"burstCount"` // DurationInSec is the time interval in statistic // DurationInSec only takes effect when MetricType is QPS DurationInSec int64 `json:"durationInSec"` // ParamsMaxCapacity is the max capacity of cache statistic ParamsMaxCapacity int64 `json:"paramsMaxCapacity"` SpecificItems []SpecificValue `json:"specificItems"` }
type MockPropertyHandler ¶
func (*MockPropertyHandler) Handle ¶
func (m *MockPropertyHandler) Handle(src []byte) error
type PropertyConverter ¶
PropertyConverter func is to convert source message bytes to the specific property. the first return value: is the real property; the second return value: return nil if succeed to convert src, if not return the detailed error when convert src. if src is nil or len(src)==0, the return value is (nil,nil)
type PropertyHandler ¶
type PropertyHandler interface { // handle the current property Handle(src []byte) error // contains filtered or unexported methods }
func NewFlowRulesHandler ¶
func NewFlowRulesHandler(converter PropertyConverter) PropertyHandler
func NewHotSpotParamRulesHandler ¶
func NewHotSpotParamRulesHandler(converter PropertyConverter) PropertyHandler
type PropertyUpdater ¶
type PropertyUpdater func(data interface{}) error
PropertyUpdater func is to update the specific properties to downstream. return nil if succeed to update, if not, return the error.
type SpecificValue ¶
type SpecificValue struct { ValKind ParamKind `json:"valKind"` ValStr string `json:"valStr"` Threshold int64 `json:"threshold"` }
SpecificValue indicates the specific param, contain the supported param kind and concrete value.
func (*SpecificValue) String ¶
func (s *SpecificValue) String() string