registry

package
v0.0.0-...-e6c9272 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*RegisteredFunction)

Option is an option used when registering a function.

func WithName

func WithName(name string) Option

func WithPath

func WithPath(path string) Option

type RegisteredFunction

type RegisteredFunction struct {
	Name         string                                         // The name of the function
	Path         string                                         // The serving path of the function
	CloudEventFn func(context.Context, cloudevents.Event) error // Optional: The user's CloudEvent function
	HTTPFn       func(http.ResponseWriter, *http.Request)       // Optional: The user's HTTP function
	EventFn      interface{}                                    // Optional: The user's Event function
	TypedFn      interface{}                                    // Optional: The user's typed function
}

RegisteredFunction represents a function that has been registered with the registry.

type Registry

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

Registry is a registry of functions.

func Default

func Default() *Registry

Default returns the default, singleton registry instance.

func New

func New() *Registry

func (*Registry) GetAllFunctions

func (r *Registry) GetAllFunctions() []*RegisteredFunction

GetAllFunctions returns all the registered functions.

func (*Registry) GetLastFunctionWithoutName

func (r *Registry) GetLastFunctionWithoutName() *RegisteredFunction

GetLastFunctionWithoutName returns the last function that's not registered declaratively. As the function is registered without a name, it can not be found by setting FUNCTION_TARGET when deploying. In this case, the last function that's not registered declaratively will be served.

func (*Registry) GetRegisteredFunction

func (r *Registry) GetRegisteredFunction(name string) (*RegisteredFunction, bool)

GetRegisteredFunction a registered function by name

func (*Registry) RegisterCloudEvent

func (r *Registry) RegisterCloudEvent(fn func(context.Context, cloudevents.Event) error, options ...Option) error

RegisterCloudEvent registers a CloudEvent function.

func (*Registry) RegisterEvent

func (r *Registry) RegisterEvent(fn interface{}, options ...Option) error

RegisterEvent registers an Event function.

func (*Registry) RegisterHTTP

func (r *Registry) RegisterHTTP(fn func(http.ResponseWriter, *http.Request), options ...Option) error

RegisterHTTP registes a HTTP function.

func (*Registry) RegisterTyped

func (r *Registry) RegisterTyped(fn interface{}, options ...Option) error

RegisterTyped registers a strongly typed function.

func (*Registry) Reset

func (r *Registry) Reset()

Jump to

Keyboard shortcuts

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