Documentation ¶
Index ¶
- Constants
- func GetFilterRegistry() map[string]Filter
- func Register(f Filter)
- type Filter
- type FilterMetaSpec
- type FilterSpec
- 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)
- func (hp *HTTPPipeline) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object, ...)
- func (hp *HTTPPipeline) Init(superSpec *supervisor.Spec, super *supervisor.Supervisor, ...)
- func (hp *HTTPPipeline) Kind() string
- func (hp *HTTPPipeline) Status() *supervisor.Status
- type PipelineContext
- 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, super *supervisor.Supervisor) // 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, super *supervisor.Supervisor) // 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"` }
FilterMetaSpec is metadata for all specs.
func (*FilterMetaSpec) Validate ¶ added in v1.0.1
func (meta *FilterMetaSpec) Validate() error
type FilterSpec ¶
type FilterSpec struct {
// contains filtered or unexported fields
}
FilterSpec is the universal spec for all filters.
func NewFilterSpec ¶
func NewFilterSpec(meta *FilterMetaSpec, filterSpec interface{}) (*FilterSpec, error)
NewFilterSpec creates a fileter spec.
func (*FilterSpec) FilterSpec ¶
func (s *FilterSpec) FilterSpec() interface{}
FilterSpec returns the filter spec.
func (*FilterSpec) RootFilter ¶
func (s *FilterSpec) RootFilter() Filter
RootFilter returns the root filter of the filter spec.
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)
func (*HTTPPipeline) Inherit ¶
func (hp *HTTPPipeline) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object, super *supervisor.Supervisor, muxMapper protocol.MuxMapper)
Inherit inherits previous generation of HTTPPipeline.
func (*HTTPPipeline) Init ¶
func (hp *HTTPPipeline) Init(superSpec *supervisor.Spec, super *supervisor.Supervisor, muxMapper protocol.MuxMapper)
Init initilizes 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 genreated by Runtime.
type PipelineContext ¶
type PipelineContext struct {
FilterStats *FilterStat
}
PipelineContext contains the context of the HTTPPipeline.
func GetPipelineContext ¶
func GetPipelineContext(ctx context.HTTPContext) (*PipelineContext, bool)
GetPipelineContext returns the corresponding PipelineContext of the HTTPContext, and a bool flag to represent it succeed or not.