processors

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseProcessor

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

BaseProcessor provoides implementation to set and get next processor. It can gracefully handle the case where the next processor doesn't exist.

func (*BaseProcessor) Next

func (p *BaseProcessor) Next() Interface

Next returns the next processor otherwise it will return a no-op processor so that caller doesn't need to worry about calling a nil processor.

func (*BaseProcessor) WithNext

WithNext sets the next Processor to pass the event.

type ChainableProcessor

type ChainableProcessor interface {
	Interface

	// WithNext sets the next Processor to pass the event.
	WithNext(ChainableProcessor) ChainableProcessor
}

ChainableProcessor is the interface to chainable Processor.

type FakeProcessor

type FakeProcessor struct {
	BaseProcessor

	// AlwaysErr once set will always immediately return error.
	AlwaysErr bool

	// OneTimeErr once set will immediately return an error exactly once.
	OneTimeErr bool

	// BlockUntilCancel will block until context gets cancelled only
	// if no error return is required.
	BlockUntilCancel bool

	// PrevEventsCh records the events from the previous processor.
	PrevEventsCh chan *event.Event

	// InterceptFunc delegates the event modification.
	// If nil, the original event will be passed.
	InterceptFunc func(context.Context, *event.Event) *event.Event

	// WasCancelled records whether the processing was cancelled.
	WasCancelled bool
	// contains filtered or unexported fields
}

FakeProcessor is a fake processor used for testing.

func (*FakeProcessor) Lock

func (p *FakeProcessor) Lock() func()

Lock locks the FakeProcessor for any shared state change in different goroutines.

func (*FakeProcessor) Process

func (p *FakeProcessor) Process(ctx context.Context, event *event.Event) error

Process processes the event.

type Interface

type Interface interface {
	// Process processes an event. It may decide to terminate the processing early
	// or it can pass the event to the next Processor for further processing.
	Process(ctx context.Context, e *event.Event) error
	// Next returns the next Processor to process events.
	Next() Interface
}

Interface is the interface to process an event. If a processor can rely on its successor(s) for timeout, then it shouldn't explicitly handle timeout. If a processor has some internal long running processing, then it must handle timeout by itself.

func ChainProcessors

func ChainProcessors(first ChainableProcessor, rest ...ChainableProcessor) Interface

ChainProcessors chains the given processors in order.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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