events

package
v0.0.0-...-2942e7d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

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