cloudevents

package
v1.1.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginsRoot = root + ".plugins"
)

Variables

This section is empty.

Functions

func HandleDiscardEventsIDValue

func HandleDiscardEventsIDValue() string

HandleDiscardEventsIDValue returns the event IDs to be discarded comma-separated from the configuration via "faas.cloudevents.handle.discard.ids" key.

func HandlerWrapperModule

func HandlerWrapperModule() fx.Option

HandlerWrapperModule returns fx module for initialization of event handler wrapped in middleware.

The module is only loaded once.

func HelperModule

func HelperModule(extraOptions fx.Option) fx.Option

HelperModule returns fx module for initialization of helper to start HTTP client for handlers.

The module is only loaded once.

Types

type Handler

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

Handler can be used to process events.

func NewHandler

func NewHandler(h *HandlerWrapper) *Handler

NewHandler creates a new handler wrapped in middleware.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, in v2.Event) (out *v2.Event, err error)

Handle processes an event by calling the necessary middlewares.

type HandlerWrapper

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

HandlerWrapper can be used to process events wrapped in middleware.

func NewDefaultHandlerWrapper

func NewDefaultHandlerWrapper(handler cloudevents.Handler, middlewares ...Middleware) *HandlerWrapper

NewDefaultHandlerWrapper creates a new handler wrapped in middleware.

func NewHandlerWrapper

func NewHandlerWrapper(handler cloudevents.Handler, options *HandlerWrapperOptions, middlewares ...Middleware) *HandlerWrapper

NewHandlerWrapper creates a new handler with options and wrapped in middleware.

func (*HandlerWrapper) Process

func (h *HandlerWrapper) Process(parentCtx context.Context, inouts []*InOut) (err error)

Process processes events.

type HandlerWrapperOptions

type HandlerWrapperOptions struct {
	IDsToDiscard []string
}

HandlerWrapperOptions represents options for handler wrapped in middleware.

func DefaultHandlerWrapperOptions

func DefaultHandlerWrapperOptions() (*HandlerWrapperOptions, error)

DefaultHandlerWrapperOptions returns handler wrapped in middleware options.

type Helper

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

Helper assists in creating event handlers.

func NewHelper

func NewHelper(ctx context.Context, handler *HandlerWrapper) *Helper

NewHelper returns a new Helper.

func (*Helper) Start

func (h *Helper) Start()

Start starts HTTP client for handle events.

type InOut

type InOut struct {
	In      *event.Event
	Out     *event.Event
	Err     error
	Context context.Context
}

InOut represents input and output events.

type Middleware

type Middleware interface {
	BeforeAll(ctx context.Context, inout []*InOut) (context.Context, error)
	Before(ctx context.Context, in *v2.Event) (context.Context, error)
	After(ctx context.Context, in v2.Event, out *v2.Event, err error) (context.Context, error)
	AfterAll(ctx context.Context, inout []*InOut) (context.Context, error)
	Close(ctx context.Context) error
}

Middleware defines an interface to process middleware.

func NewUnimplementedMiddleware

func NewUnimplementedMiddleware() Middleware

NewUnimplementedMiddleware returns a default middleware implementation.

type UnimplementedMiddleware

type UnimplementedMiddleware struct {
}

UnimplementedMiddleware defines default implementation for middleware.

func (UnimplementedMiddleware) After

func (u UnimplementedMiddleware) After(ctx context.Context, in v2.Event, out *v2.Event, err error) (context.Context, error)

After is called after each handler, but this implementation does nothing.

func (UnimplementedMiddleware) AfterAll

func (u UnimplementedMiddleware) AfterAll(ctx context.Context, inout []*InOut) (context.Context, error)

AfterAll is called after all handlers, but this implementation does nothing.

func (UnimplementedMiddleware) Before

Before is called before each handler, but this implementation does nothing.

func (UnimplementedMiddleware) BeforeAll

func (u UnimplementedMiddleware) BeforeAll(ctx context.Context, inout []*InOut) (context.Context, error)

BeforeAll is called before all handlers, but this implementation does nothing.

func (UnimplementedMiddleware) Close

Close is called after the AfterAll hook to free any resources. In this implementation nothing is done.

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

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