event

package
v0.0.0-...-d16afb3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TypePrefix = "io.argoproj.argocd-agent.event"

Variables

View Source
var (
	ErrEventDiscarded  error = errors.New("event discarded")
	ErrEventNotAllowed error = errors.New("event not allowed in this agent mode")
)

Functions

func EventID

func EventID(ev *cloudevents.Event) string

func IsEventDiscarded

func IsEventDiscarded(err error) bool

func IsEventNotAllowed

func IsEventNotAllowed(err error) bool

func NewEventDiscardedErr

func NewEventDiscardedErr(format string, a ...any) error

func NewEventNotAllowedErr

func NewEventNotAllowedErr(format string, a ...any) error

func ResourceID

func ResourceID(ev *cloudevents.Event) string

Types

type Event

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

Event is the 'on the wire' representation of an event, and is parsed by from protobuf via FromWire

func FromWire

func FromWire(pev *pb.CloudEvent) (*Event, error)

FromWire validates an event from the wire in protobuf format, converts it into an Event object and returns it. If the event on the wire is invalid, or could not be converted for another reason, FromWire returns an error.

func New

func New(ev *cloudevents.Event, target EventTarget) *Event

func (Event) AppProject

func (ev Event) AppProject() (*v1alpha1.AppProject, error)

func (Event) Application

func (ev Event) Application() (*v1alpha1.Application, error)

func (Event) EventID

func (ev Event) EventID() string

func (Event) ResourceID

func (ev Event) ResourceID() string

func (Event) Target

func (ev Event) Target() EventTarget

func (Event) Type

func (ev Event) Type() EventType

type EventSource

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

EventSource is a utility to construct new 'cloudevents.Event' events for a given 'source'

func NewEventSource

func NewEventSource(source string) *EventSource

func (EventSource) AppProjectEvent

func (evs EventSource) AppProjectEvent(evType EventType, appProject *v1alpha1.AppProject) *cloudevents.Event

func (EventSource) ApplicationEvent

func (evs EventSource) ApplicationEvent(evType EventType, app *v1alpha1.Application) *cloudevents.Event

func (EventSource) ProcessedEvent

func (evs EventSource) ProcessedEvent(evType EventType, ev *Event) *cloudevents.Event

type EventTarget

type EventTarget string
const (
	TargetUnknown     EventTarget = "unknown"
	TargetApplication EventTarget = "application"
	TargetAppProject  EventTarget = "appproject"
	TargetEventAck    EventTarget = "eventProcessed"
)

func Target

func Target(raw *cloudevents.Event) EventTarget

func (EventTarget) String

func (t EventTarget) String() string

type EventType

type EventType string
const (
	Ping            EventType = TypePrefix + ".ping"
	Pong            EventType = TypePrefix + ".pong"
	Create          EventType = TypePrefix + ".create"
	Delete          EventType = TypePrefix + ".delete"
	Update          EventType = TypePrefix + ".update"
	SpecUpdate      EventType = TypePrefix + ".spec-update"
	StatusUpdate    EventType = TypePrefix + ".status-update"
	OperationUpdate EventType = TypePrefix + ".operation-update"
	EventProcessed  EventType = TypePrefix + ".processed"
)

Supported EventTypes that are sent agent <-> principal

func (EventType) String

func (t EventType) String() string

type EventWriter

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

EventWriter keeps track of the latest event for resources and sends them on a given gRPC stream. It resends the event with exponential backoff until the event is ACK'd and removed from its list.

func NewEventWriter

func NewEventWriter(target streamWriter) *EventWriter

func (*EventWriter) Add

func (ew *EventWriter) Add(ev *cloudevents.Event)

func (*EventWriter) Get

func (ew *EventWriter) Get(resID string) *eventMessage

func (*EventWriter) Remove

func (ew *EventWriter) Remove(ev *cloudevents.Event)

func (*EventWriter) SendWaitingEvents

func (ew *EventWriter) SendWaitingEvents(ctx context.Context)

SendWaitingEvents will periodically send the events waiting in the EventWriter. Note: This function will never return unless the context is done, and therefore should be started in a separate goroutine.

Jump to

Keyboard shortcuts

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