bus

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package bus provides access to a singleton instance of an event bus (provided by the calling application). These events can provide static information, but also have an object as a payload for which the consumer can poll for updates.

Note that the singleton instance is only allowed to publish events and not subscribe to them --this is intentional. Internal library interactions should continue to use traditional in-execution-path approaches for data sharing (e.g. function returns and channels) and not depend on bus subscriptions for critical interactions (e.g. one part of the lib publishes an event and another part of the lib subscribes and reacts to that event). The bus is provided only as a means for consumers to observe events emitted from the library (such as to provide a rich UI) and not to allow consumers to augment or otherwise change execution.

Index

Constants

View Source
const (
	StartScanTryFetchImageID       EventType = "start-scan-fetch-image-id"
	NewVersionAvailable            EventType = "new-version-event"
	NewMessageDetected             EventType = "new-message-event"
	NewErrorDetected               EventType = "new-error-event"
	NewCollectLayers               EventType = "new-collect-layers"
	ScanStarted                    EventType = "image-scanning-started-event"
	ScanFinished                   EventType = "image-scanning-finished-event"
	PrintSBOM                      EventType = "print-sbom-event"
	PrintPayload                   EventType = "print-payload-event"
	ValidateFinishedWithViolations EventType = "validate-finished-with-violations"
	ValidateFinishedSuccessfully   EventType = "validate-finished-successfully"

	PullDockerImage = EventType(stereoevent.PullDockerImage)
	FetchImage      = EventType(stereoevent.FetchImage)
	ReadImage       = EventType(stereoevent.ReadImage)
	ReadLayer       = EventType(stereoevent.ReadLayer)

	CatalogerStarted = EventType(syftevent.PackageCatalogerStarted)
)

All the event types for the bus.

Variables

This section is empty.

Functions

func EventChan

func EventChan() chan Event

EventChan will return the event channel.

func Publish

func Publish(event Event)

Publish an event onto the channel. If there is no channel set by the calling application, this does nothing.

func SetEventChan

func SetEventChan(c chan Event)

SetEventChan sets the singleton event channel.

Types

type ErrorEvent

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

ErrorEvent is the NewErrorDetected type event.

func NewErrorEvent

func NewErrorEvent(err error) *ErrorEvent

NewErrorEvent returns a NewErrorDetected type event.

func (ErrorEvent) ExitCode

func (e ErrorEvent) ExitCode() int

ExitCode returns the exit code of the error of the event.

type Event

type Event interface {
	Type() EventType
	Value() interface{}
	IsEnd() bool
}

Event is the interface for the message in the bus.

func NewEvent

func NewEvent(eventType EventType, value interface{}, isEnd bool) Event

NewEvent returns a base event.

func NewMessageEvent

func NewMessageEvent(msg string, isEnd bool) Event

NewMessageEvent returns a NewMessageDetected type event.

func NewVersionEvent

func NewVersionEvent(version string) Event

NewVersionEvent returns a NewVersionAvailable type event.

type EventType

type EventType string

EventType is the type of event message.

Jump to

Keyboard shortcuts

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