event

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultType holds a default type for an event.
	DefaultType = "dev.knative.cli.plugin.event.generic"
)

Variables

View Source
var (
	// ErrCantMarshalAsJSON is returned if given CE data can't be marshalled
	// as JSON.
	ErrCantMarshalAsJSON = errors.New("can't marshal as JSON")

	// ErrCantSetField is returned if given field can't be applied.
	ErrCantSetField = errors.New("can't set field")
)
View Source
var ErrCantSentEvent = errors.New("can't sent event")

ErrCantSentEvent if event can't be sent.

View Source
var ErrUnexpected = errors.New("unexpected")

ErrUnexpected if unexpected error found.

Functions

func CreateFromSpec

func CreateFromSpec(spec *Spec) (*cloudevents.Event, error)

CreateFromSpec will create an event by parsing given args.

func DefaultSource

func DefaultSource() string

DefaultSource holds a default source of an event.

func NewDefault

func NewDefault() *cloudevents.Event

NewDefault creates a default CloudEvent.

func NewID

func NewID() string

NewID creates a new ID for an event.

Types

type Binding

type Binding struct {
	CreateSender
	k8s.NewKubeClients
}

Binding holds injectable dependencies.

func (Binding) NewSender

func (b Binding) NewSender(cfg *k8s.Configurator, target *Target) (Sender, error)

NewSender will create a sender that can send event to cluster.

type CreateSender

type CreateSender func(cfg *k8s.Configurator, target *Target) (Sender, error)

CreateSender creates a Sender.

type FieldSpec

type FieldSpec struct {
	Path  string
	Value interface{}
}

FieldSpec holds a specification of a event's data field.

type Sender

type Sender interface {
	// Send will send cloudevents.Event to configured target, or return an error
	// if one occurs.
	Send(ctx context.Context, ce cloudevents.Event) error
}

Sender will send event to specified target.

type Spec

type Spec struct {
	Type   string
	ID     string
	Source string
	Fields []FieldSpec
}

Spec holds specification of event to be created.

func (*Spec) AddField

func (s *Spec) AddField(path string, val interface{})

AddField will add a field to the spec.

type Target

type Target struct {
	*sink.Reference
	RelativeURI string
}

Target represents the endpoint to which the event should be sent.

Jump to

Keyboard shortcuts

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