Documentation ¶
Index ¶
- Constants
- type Action
- type Callbacks
- type Config
- type DefaultCallbacks
- func (dc *DefaultCallbacks) AfterBlock(filter *StreamFilter, ctx context.Context, headers types.HeaderMap, ...)
- func (dc *DefaultCallbacks) AfterPass(filter *StreamFilter, ctx context.Context, headers types.HeaderMap, ...)
- func (dc *DefaultCallbacks) Enabled() bool
- func (dc *DefaultCallbacks) Exit(filter *StreamFilter)
- func (dc *DefaultCallbacks) Init()
- func (dc *DefaultCallbacks) ParseResource(ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, ...) *ParsedResource
- type ParsedResource
- type StreamFilter
- type StreamFilterFactory
Constants ¶
const FlowControlFilterName = "flowControlFilter"
FlowControlFilterName is the flow control stream filter name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callbacks ¶
type Callbacks interface { Init() ParseResource(ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap) *ParsedResource AfterBlock(flowControlFilter *StreamFilter, ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap) AfterPass(flowControlFilter *StreamFilter, ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap) Exit(filter *StreamFilter) Enabled() bool }
Callbacks defines the flow control callbacks
type Config ¶
type Config struct { AppName string `json:"app_name"` LogPath string `json:"log_path"` GlobalSwitch bool `json:"global_switch"` Monitor bool `json:"monitor"` KeyType api.ProtocolResourceName `json:"limit_key_type"` Action Action `json:"action"` Rules []*flow.FlowRule `json:"rules"` }
Config represents the flow control configurations.
type DefaultCallbacks ¶
type DefaultCallbacks struct {
// contains filtered or unexported fields
}
DefaultCallbacks represents the default flow control filter implementation.
func (*DefaultCallbacks) AfterBlock ¶
func (dc *DefaultCallbacks) AfterBlock(filter *StreamFilter, ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap)
AfterBlock sends response directly.
func (*DefaultCallbacks) AfterPass ¶
func (dc *DefaultCallbacks) AfterPass(filter *StreamFilter, ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap)
AfterPass is a no-op.
func (*DefaultCallbacks) Enabled ¶
func (dc *DefaultCallbacks) Enabled() bool
Enabled reports whether the callbacks enabled.
func (*DefaultCallbacks) Exit ¶
func (dc *DefaultCallbacks) Exit(filter *StreamFilter)
Exit is a no-op.
func (*DefaultCallbacks) ParseResource ¶
func (dc *DefaultCallbacks) ParseResource(ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap) *ParsedResource
ParseResource parses resource from context.
type ParsedResource ¶
type ParsedResource struct {
// contains filtered or unexported fields
}
ParsedResource contains the parsed resource wrapper and entry options.
type StreamFilter ¶
type StreamFilter struct { Entry *base.SentinelEntry BlockError *base.BlockError Callbacks Callbacks // contains filtered or unexported fields }
StreamFilter represents the flow control stream filter.
func NewStreamFilter ¶
func NewStreamFilter(callbacks Callbacks) *StreamFilter
NewStreamFilter creates flow control filter.
func (*StreamFilter) OnReceive ¶
func (f *StreamFilter) OnReceive(ctx context.Context, headers types.HeaderMap, buf types.IoBuffer, trailers types.HeaderMap) api.StreamFilterStatus
OnReceive creates resource and judges whether current request should be blocked.
func (*StreamFilter) SetReceiveFilterHandler ¶
func (f *StreamFilter) SetReceiveFilterHandler(handler api.StreamReceiverFilterHandler)
type StreamFilterFactory ¶
type StreamFilterFactory struct {
// contains filtered or unexported fields
}
StreamFilterFactory represents the stream filter factory.
func (*StreamFilterFactory) CreateFilterChain ¶
func (f *StreamFilterFactory) CreateFilterChain(context context.Context, callbacks api.StreamFilterChainFactoryCallbacks)
CreateFilterChain add the flow control stream filter to filter chain.