Documentation ¶
Index ¶
- Variables
- func CreateFactoryByPlugin(pluginConfig *v2.StreamFilterGoPluginConfig, ...) (api.StreamFilterChainFactory, error)
- func LoadAndRegisterStreamFilters(path string)
- func ParseAndRegisterStreamFilters(config []byte)
- func PutStreamFilterChain(chain *DefaultStreamFilterChainImpl)
- func RegisterStreamFilters(configs []StreamFilters)
- type DefaultStreamFilterChainImpl
- func (d *DefaultStreamFilterChainImpl) AddStreamAccessLog(accessLog api.AccessLog)
- func (d *DefaultStreamFilterChainImpl) AddStreamReceiverFilter(filter api.StreamReceiverFilter, p api.ReceiverFilterPhase)
- func (d *DefaultStreamFilterChainImpl) AddStreamSenderFilter(filter api.StreamSenderFilter, p api.SenderFilterPhase)
- func (d *DefaultStreamFilterChainImpl) Log(ctx context.Context, reqHeaders api.HeaderMap, respHeaders api.HeaderMap, ...)
- func (d *DefaultStreamFilterChainImpl) OnDestroy()
- func (d *DefaultStreamFilterChainImpl) RangeReceiverFilter(ctx context.Context, headers types.HeaderMap, data types.IoBuffer, ...)
- func (d *DefaultStreamFilterChainImpl) RangeSenderFilter(ctx context.Context, headers types.HeaderMap, data types.IoBuffer, ...)
- func (d *DefaultStreamFilterChainImpl) RunReceiverFilter(ctx context.Context, phase api.ReceiverFilterPhase, headers types.HeaderMap, ...) (filterStatus api.StreamFilterStatus)
- func (d *DefaultStreamFilterChainImpl) RunSenderFilter(ctx context.Context, phase api.SenderFilterPhase, headers types.HeaderMap, ...) (filterStatus api.StreamFilterStatus)
- func (d *DefaultStreamFilterChainImpl) SetReceiveFilterHandler(handler api.StreamReceiverFilterHandler)
- func (d *DefaultStreamFilterChainImpl) SetSenderFilterHandler(handler api.StreamSenderFilterHandler)
- type MockStreamFilterFactory
- type MockStreamFilterFactoryMockRecorder
- type MockStreamFilterManager
- type MockStreamFilterManagerMockRecorder
- type StreamFilterChain
- type StreamFilterFactory
- type StreamFilterFactoryImpl
- type StreamFilterManager
- type StreamFilterManagerImpl
- type StreamFilters
- type StreamFiltersConfig
- type StreamReceiverFilterIteratorHandler
- type StreamReceiverFilterStatusHandler
- type StreamSenderFilterIteratorHandler
- type StreamSenderFilterStatusHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnexpected indicate unexpected object type in sync.Map. ErrUnexpected = errors.New("unexpected object in map") // ErrInvalidKey indicate invalid stream filter config name ErrInvalidKey = errors.New("invalid key") )
Functions ¶
func CreateFactoryByPlugin ¶ added in v0.21.0
func CreateFactoryByPlugin(pluginConfig *v2.StreamFilterGoPluginConfig, factoryConfig map[string]interface{}) (api.StreamFilterChainFactory, error)
func LoadAndRegisterStreamFilters ¶
func LoadAndRegisterStreamFilters(path string)
LoadAndRegisterStreamFilters load and register stream filter config from file.
func ParseAndRegisterStreamFilters ¶
func ParseAndRegisterStreamFilters(config []byte)
ParseAndRegisterStreamFilters parse and register stream filter config from raw bytes.
func PutStreamFilterChain ¶
func PutStreamFilterChain(chain *DefaultStreamFilterChainImpl)
PutStreamFilterChain reset DefaultStreamFilterChainImpl and return it to pool.
func RegisterStreamFilters ¶
func RegisterStreamFilters(configs []StreamFilters)
RegisterStreamFilters register stream filter from config.
Types ¶
type DefaultStreamFilterChainImpl ¶
type DefaultStreamFilterChainImpl struct {
// contains filtered or unexported fields
}
DefaultStreamFilterChainImpl is default implementation of the StreamFilterChain.
func GetDefaultStreamFilterChain ¶
func GetDefaultStreamFilterChain() *DefaultStreamFilterChainImpl
GetDefaultStreamFilterChain return a pool-cached DefaultStreamFilterChainImpl.
func (*DefaultStreamFilterChainImpl) AddStreamAccessLog ¶
func (d *DefaultStreamFilterChainImpl) AddStreamAccessLog(accessLog api.AccessLog)
AddStreamAccessLog registers access logger.
func (*DefaultStreamFilterChainImpl) AddStreamReceiverFilter ¶
func (d *DefaultStreamFilterChainImpl) AddStreamReceiverFilter(filter api.StreamReceiverFilter, p api.ReceiverFilterPhase)
AddStreamReceiverFilter registers receiver filters.
func (*DefaultStreamFilterChainImpl) AddStreamSenderFilter ¶
func (d *DefaultStreamFilterChainImpl) AddStreamSenderFilter(filter api.StreamSenderFilter, p api.SenderFilterPhase)
AddStreamSenderFilter registers senderFilters.
func (*DefaultStreamFilterChainImpl) Log ¶
func (d *DefaultStreamFilterChainImpl) Log(ctx context.Context, reqHeaders api.HeaderMap, respHeaders api.HeaderMap, requestInfo api.RequestInfo)
Log invokes all access loggers.
func (*DefaultStreamFilterChainImpl) OnDestroy ¶
func (d *DefaultStreamFilterChainImpl) OnDestroy()
OnDestroy invokes the destroy callback of both sender filters and receiver filters.
func (*DefaultStreamFilterChainImpl) RangeReceiverFilter ¶ added in v0.23.0
func (d *DefaultStreamFilterChainImpl) RangeReceiverFilter(ctx context.Context, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap, handler StreamReceiverFilterIteratorHandler)
RangeReceiverFilter range receive filter.
func (*DefaultStreamFilterChainImpl) RangeSenderFilter ¶ added in v0.23.0
func (d *DefaultStreamFilterChainImpl) RangeSenderFilter(ctx context.Context, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap, handler StreamSenderFilterIteratorHandler)
RangeSenderFilter range send filter.
func (*DefaultStreamFilterChainImpl) RunReceiverFilter ¶
func (d *DefaultStreamFilterChainImpl) RunReceiverFilter(ctx context.Context, phase api.ReceiverFilterPhase, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap, statusHandler StreamReceiverFilterStatusHandler) (filterStatus api.StreamFilterStatus)
RunReceiverFilter invokes the receiver filter chain.
func (*DefaultStreamFilterChainImpl) RunSenderFilter ¶
func (d *DefaultStreamFilterChainImpl) RunSenderFilter(ctx context.Context, phase api.SenderFilterPhase, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap, statusHandler StreamSenderFilterStatusHandler) (filterStatus api.StreamFilterStatus)
RunSenderFilter invokes the sender filter chain.
func (*DefaultStreamFilterChainImpl) SetReceiveFilterHandler ¶ added in v0.22.0
func (d *DefaultStreamFilterChainImpl) SetReceiveFilterHandler(handler api.StreamReceiverFilterHandler)
SetReceiveFilterHandler set filter handler for each filter in this chain
func (*DefaultStreamFilterChainImpl) SetSenderFilterHandler ¶ added in v0.22.0
func (d *DefaultStreamFilterChainImpl) SetSenderFilterHandler(handler api.StreamSenderFilterHandler)
SetSenderFilterHandler set filter handler for each filter in this chain
type MockStreamFilterFactory ¶
type MockStreamFilterFactory struct {
// contains filtered or unexported fields
}
MockStreamFilterFactory is a mock of StreamFilterFactory interface.
func NewMockStreamFilterFactory ¶
func NewMockStreamFilterFactory(ctrl *gomock.Controller) *MockStreamFilterFactory
NewMockStreamFilterFactory creates a new mock instance.
func (*MockStreamFilterFactory) CreateFilterChain ¶
func (m *MockStreamFilterFactory) CreateFilterChain(context context.Context, callbacks api.StreamFilterChainFactoryCallbacks)
CreateFilterChain mocks base method.
func (*MockStreamFilterFactory) EXPECT ¶
func (m *MockStreamFilterFactory) EXPECT() *MockStreamFilterFactoryMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStreamFilterFactory) UpdateFactory ¶
func (m *MockStreamFilterFactory) UpdateFactory(config StreamFiltersConfig)
UpdateFactory mocks base method.
type MockStreamFilterFactoryMockRecorder ¶
type MockStreamFilterFactoryMockRecorder struct {
// contains filtered or unexported fields
}
MockStreamFilterFactoryMockRecorder is the mock recorder for MockStreamFilterFactory.
func (*MockStreamFilterFactoryMockRecorder) CreateFilterChain ¶
func (mr *MockStreamFilterFactoryMockRecorder) CreateFilterChain(context, callbacks interface{}) *gomock.Call
CreateFilterChain indicates an expected call of CreateFilterChain.
func (*MockStreamFilterFactoryMockRecorder) UpdateFactory ¶
func (mr *MockStreamFilterFactoryMockRecorder) UpdateFactory(config interface{}) *gomock.Call
UpdateFactory indicates an expected call of UpdateFactory.
type MockStreamFilterManager ¶
type MockStreamFilterManager struct {
// contains filtered or unexported fields
}
MockStreamFilterManager is a mock of StreamFilterManager interface.
func NewMockStreamFilterManager ¶
func NewMockStreamFilterManager(ctrl *gomock.Controller) *MockStreamFilterManager
NewMockStreamFilterManager creates a new mock instance.
func (*MockStreamFilterManager) AddOrUpdateStreamFilterConfig ¶
func (m *MockStreamFilterManager) AddOrUpdateStreamFilterConfig(key string, config StreamFiltersConfig) error
AddOrUpdateStreamFilterConfig mocks base method.
func (*MockStreamFilterManager) EXPECT ¶
func (m *MockStreamFilterManager) EXPECT() *MockStreamFilterManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStreamFilterManager) GetStreamFilterFactory ¶
func (m *MockStreamFilterManager) GetStreamFilterFactory(key string) StreamFilterFactory
GetStreamFilterFactory mocks base method.
type MockStreamFilterManagerMockRecorder ¶
type MockStreamFilterManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockStreamFilterManagerMockRecorder is the mock recorder for MockStreamFilterManager.
func (*MockStreamFilterManagerMockRecorder) AddOrUpdateStreamFilterConfig ¶
func (mr *MockStreamFilterManagerMockRecorder) AddOrUpdateStreamFilterConfig(key, config interface{}) *gomock.Call
AddOrUpdateStreamFilterConfig indicates an expected call of AddOrUpdateStreamFilterConfig.
func (*MockStreamFilterManagerMockRecorder) GetStreamFilterFactory ¶
func (mr *MockStreamFilterManagerMockRecorder) GetStreamFilterFactory(key interface{}) *gomock.Call
GetStreamFilterFactory indicates an expected call of GetStreamFilterFactory.
type StreamFilterChain ¶
type StreamFilterChain interface { // register StreamSenderFilter, StreamReceiverFilter and AccessLog. api.StreamFilterChainFactoryCallbacks // SetReceiveFilterHandler set filter handler for each filter in this chain SetReceiveFilterHandler(handler api.StreamReceiverFilterHandler) // SetSenderFilterHandler set filter handler for each filter in this chain SetSenderFilterHandler(handler api.StreamSenderFilterHandler) // RangeReceiverFilter range all receive filter. RangeReceiverFilter(context.Context, types.HeaderMap, types.IoBuffer, types.HeaderMap, StreamReceiverFilterIteratorHandler) // RangeSenderFilter range all send filter. RangeSenderFilter(context.Context, types.HeaderMap, types.IoBuffer, types.HeaderMap, StreamSenderFilterIteratorHandler) // invoke the receiver filter chain. RunReceiverFilter(ctx context.Context, phase api.ReceiverFilterPhase, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap, statusHandler StreamReceiverFilterStatusHandler) api.StreamFilterStatus // invoke the sender filter chain. RunSenderFilter(ctx context.Context, phase api.SenderFilterPhase, headers types.HeaderMap, data types.IoBuffer, trailers types.HeaderMap, statusHandler StreamSenderFilterStatusHandler) api.StreamFilterStatus // invoke all access log. Log(ctx context.Context, reqHeaders api.HeaderMap, respHeaders api.HeaderMap, requestInfo api.RequestInfo) // destroy the sender filter chain and receiver filter chain. OnDestroy() }
StreamFilterChain manages the lifecycle of streamFilters.
type StreamFilterFactory ¶
type StreamFilterFactory interface { // CreateFilterChain call 'CreateFilterChain' method for each api.StreamFilterChainFactory. CreateFilterChain(context context.Context, callbacks api.StreamFilterChainFactoryCallbacks) // UpdateFactory update factory according to config. UpdateFactory(config StreamFiltersConfig) }
StreamFilterFactory is a wrapper of type []api.StreamFilterChainFactory.
func NewStreamFilterFactory ¶
func NewStreamFilterFactory(config StreamFiltersConfig) StreamFilterFactory
NewStreamFilterFactory return a StreamFilterFactoryImpl struct.
type StreamFilterFactoryImpl ¶
type StreamFilterFactoryImpl struct {
// contains filtered or unexported fields
}
StreamFilterFactoryImpl is an implementation of interface StreamFilterFactory.
func (*StreamFilterFactoryImpl) CreateFilterChain ¶
func (s *StreamFilterFactoryImpl) CreateFilterChain(context context.Context, callbacks api.StreamFilterChainFactoryCallbacks)
CreateFilterChain call 'CreateFilterChain' method for each api.StreamFilterChainFactory.
func (*StreamFilterFactoryImpl) UpdateFactory ¶
func (s *StreamFilterFactoryImpl) UpdateFactory(config StreamFiltersConfig)
UpdateFactory update factory according to config.
type StreamFilterManager ¶
type StreamFilterManager interface { // AddOrUpdateStreamFilterConfig map the key to streamFilter chain config. AddOrUpdateStreamFilterConfig(key string, config StreamFiltersConfig) error // GetStreamFilterFactory return StreamFilterFactory indexed by key. GetStreamFilterFactory(key string) StreamFilterFactory }
StreamFilterManager manager the config of all StreamFilterChainFactorys, each StreamFilterChainFactory is bound to a key, which is the listenerName by now.
func GetStreamFilterManager ¶
func GetStreamFilterManager() StreamFilterManager
GetStreamFilterManager return a global singleton of StreamFilterManager.
type StreamFilterManagerImpl ¶
type StreamFilterManagerImpl struct {
// contains filtered or unexported fields
}
StreamFilterManagerImpl is an implementation of interface StreamFilterManager.
func (*StreamFilterManagerImpl) AddOrUpdateStreamFilterConfig ¶
func (s *StreamFilterManagerImpl) AddOrUpdateStreamFilterConfig(key string, config StreamFiltersConfig) error
AddOrUpdateStreamFilterConfig map the key to streamFilter chain config.
func (*StreamFilterManagerImpl) GetStreamFilterFactory ¶
func (s *StreamFilterManagerImpl) GetStreamFilterFactory(key string) StreamFilterFactory
GetStreamFilterFactory return StreamFilterFactory indexed by key.
type StreamFilters ¶
type StreamFilters struct { Name string `json:"name,omitempty"` Filters StreamFiltersConfig `json:"stream_filters,omitempty"` }
StreamFilters is the stream filter config attached with a name.
type StreamFiltersConfig ¶
StreamFiltersConfig is the stream filter config array.
type StreamReceiverFilterIteratorHandler ¶ added in v0.23.0
type StreamReceiverFilterIteratorHandler func(context.Context, types.HeaderMap, types.IoBuffer, types.HeaderMap, api.StreamReceiverFilter)
StreamReceiverFilterIteratorHandler is used to implement iterator handler for receive filter.
type StreamReceiverFilterStatusHandler ¶
type StreamReceiverFilterStatusHandler func(phase api.ReceiverFilterPhase, status api.StreamFilterStatus)
StreamReceiverFilterStatusHandler allow users to deal with the receiver filter status.
type StreamSenderFilterIteratorHandler ¶ added in v0.23.0
type StreamSenderFilterIteratorHandler func(context.Context, types.HeaderMap, types.IoBuffer, types.HeaderMap, api.StreamSenderFilter)
StreamSenderFilterIteratorHandler is used to implement iterator handler for send filter.
type StreamSenderFilterStatusHandler ¶
type StreamSenderFilterStatusHandler func(phase api.SenderFilterPhase, status api.StreamFilterStatus)
StreamSenderFilterStatusHandler allow users to deal with the sender filter status.