eventutil

package
v0.0.0-...-d19fc40 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Intentionally make it short because the additional attribute
	// increases Pubsub message size and could incur additional cost.
	HopsAttribute = "kgcphops"
)

Variables

This section is empty.

Functions

func DeleteRemainingHops

func DeleteRemainingHops(_ context.Context, event *event.Event)

DeleteRemainingHops deletes hops from the event extensions.

func GetRemainingHops

func GetRemainingHops(ctx context.Context, event *event.Event) (int32, bool)

GetRemainingHops returns the remaining hops of the event if it presents. If there is no existing hops value or an invalid one, (0, false) will be returned.

func UpdateRemainingHops

func UpdateRemainingHops(ctx context.Context, event *event.Event, preemptiveHops int32)

UpdateRemainingHops update an event with proper remaining hops. 1. If the event doesn't have an existing hops value or have an invalid hops value, it puts the preemptive hops in the event. 2. If the event has an existing valid hops value, it decrements it by 1.

Types

type ImmutableEventMessage

type ImmutableEventMessage struct {
	*binding.EventMessage
}

ImmutableEventMessage wraps binding.EventMessage and sets binary encoding to avoid mutation of the underlying event.

func NewImmutableEventMessage

func NewImmutableEventMessage(e *event.Event) ImmutableEventMessage

func (ImmutableEventMessage) ReadEncoding

func (m ImmutableEventMessage) ReadEncoding() binding.Encoding

ReadEncoding overrides the encoding used by EventMessage with EncodingBinary instead of EncodingEvent to avoid unnecessarily converting the message to an event.

type LabeledEvent

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

LabeledEvent is a wrapper of a cloudevent that allows labeling the event.

func NewLabeledEvent

func NewLabeledEvent(e *cloudevents.Event) *LabeledEvent

NewLabeledEvent creates a new LabeledEvent.

func (*LabeledEvent) Delabeled

func (le *LabeledEvent) Delabeled() *cloudevents.Event

Delabeled returns the cloudevent without labels.

func (*LabeledEvent) Event

func (le *LabeledEvent) Event() *cloudevents.Event

Event returns the LabeledEvent as a cloudevent.

func (*LabeledEvent) GetLabels

func (le *LabeledEvent) GetLabels() map[string]string

GetLabels gets all the labels as a map.

func (*LabeledEvent) WithLabel

func (le *LabeledEvent) WithLabel(key, value string) *LabeledEvent

WithLabel attaches a label to the event as an extension.

type SetRemainingHopsTransformer

type SetRemainingHopsTransformer int32

func (SetRemainingHopsTransformer) Transform

Jump to

Keyboard shortcuts

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