eventstream

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventActionComplete

type EventActionComplete struct {
	Type   EventType
	Action string
}

EventActionComplete conatins an action name to signal completion for.

type EventActionStart

type EventActionStart struct {
	Type    EventType
	Action  string
	Message string
}

EventActionStart contains an action name, and a message

type EventError

type EventError struct {
	Type  EventType
	Error string
}

EventError contains the underlying error that occured.

type EventFileFetch

type EventFileFetch struct {
	Type     EventType
	Filename string
}

EventFileFetch contains a filename that was fetched successfully.

type EventLogLine

type EventLogLine struct {
	Type    EventType
	Message string
}

EventLogLine contains a message from a log.

type EventStream

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

EventStream binds all the components of the event streaming server.

func New

func New(l hclog.Logger) *EventStream

New returns an initialized event streamer ready for use.

func (*EventStream) Handler

func (es *EventStream) Handler(w http.ResponseWriter, r *http.Request)

Handler implements the http.Handler interface so that the eventstream can be plugged into a webserver.

func (*EventStream) PublishActionComplete

func (es *EventStream) PublishActionComplete(action string)

PublishActionComplete pushes an asynchronous action complete message.

func (*EventStream) PublishActionStart

func (es *EventStream) PublishActionStart(action, msg string)

PublishActionStart pushes an asynchronous action start message.

func (*EventStream) PublishError

func (es *EventStream) PublishError(err error)

PublishError pushes an error out into the event stream.

func (*EventStream) PublishFileFetch

func (es *EventStream) PublishFileFetch(file string)

PublishFileFetch pushes a filename into the event stream.

func (*EventStream) PublishLogLine

func (es *EventStream) PublishLogLine(msg string)

PublishLogLine pushes a log message into the event stream.

type EventType

type EventType uint8

EventType is used to identify what type of event is crossing the wire.

const (
	// EventTypeUnknown is used as a zero value to ensure that this
	// always has to be set to something.
	EventTypeUnknown EventType = iota

	// EventTypeError is pushed across the wire in the event that the
	// system has encountered some kind of error that was
	// non-recoverable.
	EventTypeError

	// EventTypeLogLine is used to signify that the event in question
	// is a log line, which may be associated with one or more
	// other events.
	EventTypeLogLine

	// EventTypeActionStart is used to signal that an asynchronous
	// action has been requested, and that the system is
	// attempting to process it.
	EventTypeActionStart

	// EventTypeActionComplete is used to signal that an
	// asynchronous action has successfully completed.
	EventTypeActionComplete

	// EventTypeFileFetch is fired when a file is successfully
	// retrieved from a remote source.
	EventTypeFileFetch
)

type NullStream

type NullStream struct{}

NullStream doesn't publish events anywhere and is mostly for testing or non-server CLI cmdlets.

func NewNullStreamer

func NewNullStreamer() *NullStream

NewNullStreamer hands back a null stream instance that discards everything.

func (*NullStream) PublishActionComplete

func (ns *NullStream) PublishActionComplete(_ string)

PublishActionComplete discards all actions.

func (*NullStream) PublishActionStart

func (ns *NullStream) PublishActionStart(_, _ string)

PublishActionStart discards all actions.

func (*NullStream) PublishError

func (ns *NullStream) PublishError(_ error)

PublishError discards all errors.

func (*NullStream) PublishFileFetch

func (ns *NullStream) PublishFileFetch(_ string)

PublishFileFetch discards all filenames.

func (*NullStream) PublishLogLine

func (ns *NullStream) PublishLogLine(_ string)

PublishLogLine discards all log lines.

Jump to

Keyboard shortcuts

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