Documentation
¶
Index ¶
- Constants
- func GetFilterRegistry() map[string]Filter
- func Register(f Filter)
- type Filter
- type FilterMetaSpec
- type FilterSpec
- func (s *FilterSpec) FilterSpec() interface{}
- func (s *FilterSpec) Kind() string
- func (s *FilterSpec) Name() string
- func (s *FilterSpec) Pipeline() string
- func (s *FilterSpec) RawSpec() map[string]interface{}
- func (s *FilterSpec) RootFilter() Filter
- func (s *FilterSpec) Super() *supervisor.Supervisor
- func (s *FilterSpec) YAMLConfig() string
- type FilterStat
- type Flow
- type HTTPPipeline
- func (hp *HTTPPipeline) Category() supervisor.ObjectCategory
- func (hp *HTTPPipeline) Close()
- func (hp *HTTPPipeline) DefaultSpec() interface{}
- func (hp *HTTPPipeline) Handle(ctx context.HTTPContext) string
- func (hp *HTTPPipeline) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object, ...)
- func (hp *HTTPPipeline) Init(superSpec *supervisor.Spec, muxMapper protocol.MuxMapper)
- func (hp *HTTPPipeline) Kind() string
- func (hp *HTTPPipeline) Status() *supervisor.Status
- type Spec
- type Status
Constants ¶
const ( // Category is the category of HTTPPipeline. Category = supervisor.CategoryPipeline // Kind is the kind of HTTPPipeline. Kind = "HTTPPipeline" // LabelEND is the built-in label for jumping of flow. LabelEND = "END" )
Variables ¶
This section is empty.
Functions ¶
func GetFilterRegistry ¶
GetFilterRegistry get the filter registry.
Types ¶
type Filter ¶
type Filter interface {
// Kind returns the unique kind name to represent itself.
Kind() string
// DefaultSpec returns the default spec.
DefaultSpec() interface{}
// Description returns the description of the filter.
Description() string
// Results returns all possible results, the normal result
// (i.e. empty string) could not be in it.
Results() []string
// Init initializes the Filter.
Init(filterSpec *FilterSpec)
// Inherit also initializes the Filter.
// But it needs to handle the lifecycle of the previous generation.
// So it's own responsibility for the filter to inherit and clean the previous generation stuff.
// The http pipeline won't call Close for the previous generation.
Inherit(filterSpec *FilterSpec, previousGeneration Filter)
// Handle handles one HTTP request, all possible results
// need be registered in Results.
Handle(context.HTTPContext) (result string)
// Status returns its runtime status.
// It could return nil.
Status() interface{}
// Close closes itself.
Close()
}
Filter is the common interface for filters handling HTTP traffic.
type FilterMetaSpec ¶
type FilterMetaSpec struct {
Name string `yaml:"name" jsonschema:"required,format=urlname"`
Kind string `yaml:"kind" jsonschema:"required"`
Pipeline string `yaml:"-" jsonschema:"-"`
}
FilterMetaSpec is metadata for all specs.
func (*FilterMetaSpec) Validate ¶ added in v1.0.1
func (meta *FilterMetaSpec) Validate() error
Validate validates the meta information
type FilterSpec ¶
type FilterSpec struct {
// contains filtered or unexported fields
}
FilterSpec is the universal spec for all filters.
func MockFilterSpec ¶ added in v1.5.0
func MockFilterSpec(super *supervisor.Supervisor, rawSpec map[string]interface{}, yamlConfig string, meta *FilterMetaSpec, filterSpec interface{}) *FilterSpec
MockFilterSpec help to create FilterSpec for test
func NewFilterSpec ¶
func NewFilterSpec(originalRawSpec map[string]interface{}, super *supervisor.Supervisor) ( s *FilterSpec, err error)
NewFilterSpec creates a filter spec and validates it.
func (*FilterSpec) FilterSpec ¶
func (s *FilterSpec) FilterSpec() interface{}
FilterSpec returns the filter spec in its own type.
func (*FilterSpec) Pipeline ¶ added in v1.3.0
func (s *FilterSpec) Pipeline() string
Pipeline returns the name of the pipeline this filter belongs to.
func (*FilterSpec) RawSpec ¶ added in v1.1.0
func (s *FilterSpec) RawSpec() map[string]interface{}
RawSpec returns raw spec in type map[string]interface{}.
func (*FilterSpec) RootFilter ¶
func (s *FilterSpec) RootFilter() Filter
RootFilter returns the root filter of the filter spec.
func (*FilterSpec) Super ¶ added in v1.1.0
func (s *FilterSpec) Super() *supervisor.Supervisor
Super returns super
func (*FilterSpec) YAMLConfig ¶
func (s *FilterSpec) YAMLConfig() string
YAMLConfig returns the config in yaml format.
type FilterStat ¶
type FilterStat struct {
Name string
Kind string
Result string
Duration time.Duration
Next []*FilterStat
}
FilterStat records the statistics of the running filter.
type Flow ¶
type Flow struct {
Filter string `yaml:"filter" jsonschema:"required,format=urlname"`
JumpIf map[string]string `yaml:"jumpIf" jsonschema:"omitempty"`
}
Flow controls the flow of pipeline.
type HTTPPipeline ¶
type HTTPPipeline struct {
// contains filtered or unexported fields
}
HTTPPipeline is Object HTTPPipeline.
func (*HTTPPipeline) Category ¶
func (hp *HTTPPipeline) Category() supervisor.ObjectCategory
Category returns the category of HTTPPipeline.
func (*HTTPPipeline) DefaultSpec ¶
func (hp *HTTPPipeline) DefaultSpec() interface{}
DefaultSpec returns the default spec of HTTPPipeline.
func (*HTTPPipeline) Handle ¶
func (hp *HTTPPipeline) Handle(ctx context.HTTPContext) string
Handle is the handler to deal with HTTP
func (*HTTPPipeline) Inherit ¶
func (hp *HTTPPipeline) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object, muxMapper protocol.MuxMapper)
Inherit inherits previous generation of HTTPPipeline.
func (*HTTPPipeline) Init ¶
func (hp *HTTPPipeline) Init(superSpec *supervisor.Spec, muxMapper protocol.MuxMapper)
Init initializes HTTPPipeline.
func (*HTTPPipeline) Kind ¶
func (hp *HTTPPipeline) Kind() string
Kind returns the kind of HTTPPipeline.
func (*HTTPPipeline) Status ¶
func (hp *HTTPPipeline) Status() *supervisor.Status
Status returns Status generated by Runtime.