event

package
v0.41.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultType holds a default type for a 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 AddressableSpec

type AddressableSpec struct {
	*tracker.Reference
	URI             *apis.URL
	SenderNamespace string
}

AddressableSpec specify destination of a event to be sent, as well as sender namespace that should be used to create a sender Job in.

type Binding

type Binding struct {
	CreateSender
	DefaultNamespace
}

Binding holds injectable dependencies.

func (Binding) NewSender

func (b Binding) NewSender(target *Target) (Sender, error)

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

type CreateSender

type CreateSender func(target *Target) (Sender, error)

CreateSender creates a Sender.

type DefaultNamespace

type DefaultNamespace func(props *Properties) (string, error)

DefaultNamespace returns a default namespace for connected K8s cluster or error is namespace can't be determined.

type FieldSpec

type FieldSpec struct {
	Path  string
	Value interface{}
}

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

type KnPluginOptions

type KnPluginOptions struct {
	KubeconfigOptions
}

KnPluginOptions holds options inherited to every Kn plugin.

type KubeconfigOptions

type KubeconfigOptions struct {
	Path    string
	Context string
	Cluster string
}

KubeconfigOptions holds options for Kubernetes Client.

type Properties

type Properties struct {
	KnPluginOptions
	Log *zap.SugaredLogger
}

Properties holds a general properties.

type Sender

type Sender interface {
	// Send will send cloudevents.Event to configured target, or return an error
	// if one occur.
	Send(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 {
	Type           TargetType
	URLVal         *url.URL
	AddressableVal *AddressableSpec
	*Properties
}

Target is a target to send event to.

type TargetType

type TargetType int

TargetType specify a type of a event target.

const (
	// TargetTypeReachable specify a type of event target that is network
	// reachable, and direct HTTP communication can be performed.
	TargetTypeReachable TargetType = iota

	// TargetTypeAddressable represent a type of event target that is cluster
	// private, and direct communication can't be performed. In this case in
	// cluster sender Job will be created to send the event.
	TargetTypeAddressable
)

Jump to

Keyboard shortcuts

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