cloudevents

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ce implements a Functions CloudEvent middleware for use by scaffolding which exposes a function as a network service which handles Cloud Events.

Index

Constants

View Source
const (
	LogDebug    = logLevel(zerolog.DebugLevel)
	LogInfo     = logLevel(zerolog.InfoLevel)
	LogWarn     = logLevel(zerolog.WarnLevel)
	LogDisabled = logLevel(zerolog.Disabled)
)
View Source
const (
	DefaultLogLevel       = LogDebug
	DefaultListenAddress  = "127.0.0.1:8080"
	ServerShutdownTimeout = 30 * time.Second
	InstanceStopTimeout   = 30 * time.Second
)

Variables

This section is empty.

Functions

func SetLogLevel added in v0.20.0

func SetLogLevel(l logLevel)

SetLogLevel to LogDebug, LogInfo, LogWarn, or LogDisabled Errors are always returned as values.

func Start

func Start(f any) error

Start an intance using a new Service Note that for CloudEvent Handlers this effectively accepts ANY because the actual type of the handler function is determined later.

Types

type DefaultHandler

type DefaultHandler struct {
	Handler any
}

DefaultHandler is used for simple static function implementations which need only define a single exported function named Handle which must be of a signature understood by the CloudEvents SDK.

type Handler

type Handler any

Handler is a CloudEvent function Handler, which is invoked when it receives a cloud event. It must implement one of the following methods:

Handle()
Handle() error
Handle(context.Context)
Handle(context.Context) error
Handle(event.Event)
Handle(event.Event) error
Handle(context.Context, event.Event)
Handle(context.Context, event.Event) error
Handle(event.Event) *event.Event
Handle(event.Event) (*event.Event, error)
Handle(context.Context, event.Event) *event.Event
Handle(context.Context, event.Event) (*event.Event, error)

It can optionaly implement any of Start, Stop, Ready, and Alive.

type LivenessReporter

type LivenessReporter interface {
	// Alive allows the instance to report it's liveness status.
	Alive(context.Context) (bool, error)
}

LivenessReporter is a function which defines a method to be used to determine liveness.

type ReadinessReporter

type ReadinessReporter interface {
	// Ready to be invoked or not.
	Ready(context.Context) (bool, error)
}

ReadinessReporter is a function which defines a method to be used to determine readiness.

type Service

type Service struct {
	http.Server
	// contains filtered or unexported fields
}

Service exposes a Function Instance as a an HTTP service.

func New

func New(f any) *Service

New Service which service the given instance.

func (*Service) Addr added in v0.20.0

func (s *Service) Addr() net.Addr

Addr returns the address upon which the service is listening if started; nil otherwise.

func (*Service) Alive

func (s *Service) Alive(w http.ResponseWriter, r *http.Request)

Alive handles liveness checks.

func (*Service) Ready

func (s *Service) Ready(w http.ResponseWriter, r *http.Request)

Ready handles readiness checks.

func (*Service) Start

func (s *Service) Start(ctx context.Context) (err error)

Start serving

type Starter

type Starter interface {
	// Start instance event hook.
	Start(context.Context, map[string]string) error
}

Starter is a function which defines a method to be called on function start.

type Stopper

type Stopper interface {
	// Stop instance event hook.
	Stop(context.Context) error
}

Stopper is function which defines a method to be called on function stop.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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