pipeline

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Category is the category of Pipeline.
	Category = supervisor.CategoryBusinessController

	// Kind is the kind of Pipeline.
	Kind = "Pipeline"
)

Variables

This section is empty.

Functions

func GetFilterRegistry

func GetFilterRegistry() map[string]Filter

GetFilterRegistry get the filter registry.

func Register

func Register(f Filter)

Register registers filter.

Types

type APIEntry

type APIEntry struct {
	Path    string
	Method  string
	Handler http.HandlerFunc
}

APIEntry contains filter api information

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, excluding the default result value (empty string).
	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 is Filter's responsibility to inherit and clean the previous generation.
	// The http pipeline won't call Close for the previous generation.
	Inherit(filterSpec *FilterSpec, previousGeneration Filter)

	// Status returns its runtime status.
	// It could return nil.
	Status() interface{}

	// Close closes itself.
	Close()
}

Filter is the common interface for filters.

func MockGetFilter added in v1.5.0

func MockGetFilter(p *Pipeline, name string) Filter

MockGetFilter is used to get running filter from pipeline

type FilterMetaSpec

type FilterMetaSpec struct {
	Name     string           `yaml:"name" jsonschema:"required,format=urlname"`
	Kind     string           `yaml:"kind" jsonschema:"required"`
	Pipeline string           `yaml:"-" jsonschema:"-"`
	Protocol context.Protocol `yaml:"-" jsonschema:"-"`
}

FilterMetaSpec is metadata for all specs.

type FilterSpec

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

FilterSpec is the universal spec for all filters.

func MockFilterSpec

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

func (s *FilterSpec) Kind() string

Kind returns kind.

func (*FilterSpec) Name

func (s *FilterSpec) Name() string

Name returns name.

func (*FilterSpec) Pipeline

func (s *FilterSpec) Pipeline() string

Pipeline returns the name of the pipeline this filter belongs to.

func (*FilterSpec) Protocol

func (s *FilterSpec) Protocol() context.Protocol

Protocol return protocol for this filter

func (*FilterSpec) RawSpec

func (s *FilterSpec) RawSpec() map[string]interface{}

RawSpec returns raw spec in type map[string]interface{}.

func (*FilterSpec) Super

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 Flow

type Flow struct {
	Filter string `yaml:"filter" jsonschema:"required,format=urlname"`
}

Flow controls the flow of pipeline.

type HTTPFilter

type HTTPFilter interface {
	Filter

	// Handle handles one HTTP request, all possible results
	// need be registered in Results.
	HandleHTTP(context.HTTPContext) *context.HTTPResult
}

HTTPFilter is the common interface for filters to handle http traffic.

type MQTTFilter

type MQTTFilter interface {
	Filter

	// Handle handles one MQTT request, all possible results
	// need be registered in Results.
	HandleMQTT(context.MQTTContext) *context.MQTTResult
}

MQTTFilter is the common interface for filters to handle mqtt traffic.

type MockMQTTFilter

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

MockMQTTFilter is used for test pipeline, which will count the client number of MQTTContext

func (*MockMQTTFilter) Close

func (f *MockMQTTFilter) Close()

func (*MockMQTTFilter) DefaultSpec

func (m *MockMQTTFilter) DefaultSpec() interface{}

DefaultSpec retrun default spec of MockMQTTFilter

func (*MockMQTTFilter) Description

func (f *MockMQTTFilter) Description() string

func (*MockMQTTFilter) HandleMQTT

func (m *MockMQTTFilter) HandleMQTT(ctx context.MQTTContext) *context.MQTTResult

HandleMQTT handle MQTTContext

func (*MockMQTTFilter) Inherit

func (f *MockMQTTFilter) Inherit(filterSpec *FilterSpec, previousGeneration Filter)

func (*MockMQTTFilter) Init

func (m *MockMQTTFilter) Init(filterSpec *FilterSpec)

Init init MockMQTTFilter

func (*MockMQTTFilter) Kind

func (m *MockMQTTFilter) Kind() string

Kind retrun kind of MockMQTTFilter

func (*MockMQTTFilter) Results

func (f *MockMQTTFilter) Results() []string

func (*MockMQTTFilter) Status

func (m *MockMQTTFilter) Status() interface{}

Status return status of MockMQTTFilter

type MockMQTTSpec

type MockMQTTSpec struct {
	UserName    string   `yaml:"userName" jsonschema:"required"`
	Password    string   `yaml:"password" jsonschema:"required"`
	Port        uint16   `yaml:"port" jsonschema:"required"`
	BackendType string   `yaml:"backendType" jsonschema:"required"`
	EarlyStop   bool     `yaml:"earlyStop" jsonschema:"omitempty"`
	KeysToStore []string `yaml:"keysToStore" jsonschema:"omitempty"`
	ConnectKey  string   `yaml:"connectKey" jsonschema:"omitempty"`
}

MockMQTTSpec is spec of MockMQTTFilter

type MockMQTTStatus

type MockMQTTStatus struct {
	ClientCount      map[string]int
	ClientDisconnect map[string]struct{}
	Subscribe        map[string][]string
	Unsubscribe      map[string][]string
}

MockMQTTStatus is status of MockMQTTFilter

type Pipeline

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

Pipeline is general pipeline of Easegress

func GetPipeline

func GetPipeline(name string, protocol context.Protocol) (*Pipeline, error)

GetPipeline is used to get pipeline with given name and protocol

func (*Pipeline) Category

func (p *Pipeline) Category() supervisor.ObjectCategory

Category return category of pipeline

func (*Pipeline) Close

func (p *Pipeline) Close()

Close close pipeline

func (*Pipeline) DefaultSpec

func (p *Pipeline) DefaultSpec() interface{}

DefaultSpec return default spec of pipeline

func (*Pipeline) HandleMQTT

func (p *Pipeline) HandleMQTT(ctx context.MQTTContext)

HandleMQTT used to handle MQTT context

func (*Pipeline) Inherit

func (p *Pipeline) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object)

Inherit init new pipeline based on previous pipeline

func (*Pipeline) Init

func (p *Pipeline) Init(superSpec *supervisor.Spec)

Init init pipeline

func (*Pipeline) Kind

func (p *Pipeline) Kind() string

Kind return kind of pipeline

func (*Pipeline) Status

func (p *Pipeline) Status() *supervisor.Status

Status return status of pipeline

type Spec

type Spec struct {
	Name     string                   `yaml:"-" jsonschema:"-"`
	Protocol context.Protocol         `yaml:"protocol" jsonschema:"required"`
	Flow     []Flow                   `yaml:"flow" jsonschema:"omitempty"`
	Filters  []map[string]interface{} `yaml:"filters" jsonschema:"required"`
}

Spec describes the Pipeline.

func (Spec) Validate

func (s Spec) Validate() (err error)

Validate validates Spec.

type Status

type Status struct {
	Health string `yaml:"health"`

	Filters map[string]interface{} `yaml:"filters"`
}

Status is the status of HTTPPipeline.

type TCPFilter

type TCPFilter interface {
	Filter

	HandleTCP(context.TCPContext) *context.TCPResult
}

TCPFilter is the common interface for filters to handle tcp traffic.

type UDPFilter

type UDPFilter interface {
	Filter
	HandleUDP(context.UDPContext) *context.UDPResult
}

UDPFilter is the common interface for filters to handle udp traffic.

Jump to

Keyboard shortcuts

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