datasource

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK                  = iota
	ConvertSourceError  = 1
	UpdatePropertyError = 2
	HandleSourceError   = 3
)

Variables

This section is empty.

Functions

func CircuitBreakerRuleJsonArrayParser

func CircuitBreakerRuleJsonArrayParser(src []byte) (interface{}, error)

func CircuitBreakerRulesUpdater

func CircuitBreakerRulesUpdater(data interface{}) error

CircuitBreakerRulesUpdater load the newest []cb.Rule to downstream circuit breaker component.

func FlowRuleJsonArrayParser

func FlowRuleJsonArrayParser(src []byte) (interface{}, error)

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

func HotSpotParamRuleJsonArrayParser(src []byte) (interface{}, error)

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 SystemRuleJsonArrayParser

func SystemRuleJsonArrayParser(src []byte) (interface{}, error)

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) Handle

func (b *Base) Handle(src []byte) (err error)

func (*Base) RemovePropertyHandler

func (b *Base) RemovePropertyHandler(h PropertyHandler)

type Code

type Code uint32

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 NewSystemRulesHandler

func NewSystemRulesHandler(converter PropertyConverter) *DefaultPropertyHandler

func (*DefaultPropertyHandler) Handle

func (h *DefaultPropertyHandler) Handle(src []byte) error

type Error

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

func NewError

func NewError(code Code, desc string) Error

func (Error) Code

func (e Error) Code() Code

func (Error) Error

func (e Error) Error() string

type MockPropertyHandler

type MockPropertyHandler struct {
	mock.Mock
}

func (*MockPropertyHandler) Handle

func (m *MockPropertyHandler) Handle(src []byte) error

type PropertyConverter

type PropertyConverter func(src []byte) (interface{}, error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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