events

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 21 modules, 83 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MAX_PENDING_SUBSCRIBER_EVENTS = 1024

Variables

View Source
var (
	ErrUnrecognizedEventType = errors.New("unrecognized event type")
	ErrSourceClosed          = errors.New("source closed")
	ErrNoData                = errors.New("event with no data")
)
View Source
var ErrHubAlreadyClosed = errors.New("hub already closed")
View Source
var ErrReadFromClosedSource = errors.New("read from closed source")
View Source
var ErrSendToClosedSource = errors.New("send to closed source")
View Source
var ErrSlowConsumer = errors.New("slow consumer")
View Source
var ErrSourceAlreadyClosed = errors.New("source already closed")
View Source
var ErrSubscribedToClosedHub = errors.New("subscribed to closed hub")

Functions

func NewCloseError

func NewCloseError(err error) error

func NewEventFromModelEvent

func NewEventFromModelEvent(eventID int, event models.Event) (sse.Event, error)

func NewInvalidPayloadError

func NewInvalidPayloadError(payloadType string, protoErr error) error

func NewRawEventSourceError

func NewRawEventSourceError(rawError error) error

Types

type EventSource

type EventSource interface {
	// Next reads the next event from the source. If the connection is lost, it
	// automatically reconnects.
	//
	// If the end of the stream is reached cleanly (which should actually never
	// happen), io.EOF is returned. If called after or during Close,
	// ErrSourceClosed is returned.
	Next() (models.Event, error)

	// Close releases the underlying response, interrupts any in-flight Next, and
	// prevents further calls to Next.
	Close() error
}

EventSource provides sequential access to a stream of events.

func NewEventSource

func NewEventSource(raw RawEventSource) EventSource

type Hub

type Hub interface {
	Subscribe() (EventSource, error)
	Emit(models.Event)
	Close() error

	RegisterCallback(func(count int))
	UnregisterCallback()
}

func NewHub

func NewHub(logger lager.Logger) Hub

type RawEventSource

type RawEventSource interface {
	Next() (sse.Event, error)
	Close() error
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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