observer

package
v0.5.0-rc Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package observer provides a facility for publishing progress updates and state changes from parts of the daemon, an a SSE http handler for consumers of these events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType string

EventType represents all possible types of events that can be observed.

const (
	Progress EventType = "progress"
	Started  EventType = "started"
	Finished EventType = "finished"
	Errored  EventType = "errored"
	Aborted  EventType = "aborted"
)

All values for EventType

type Observer

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

Observer recieves events via Notify, and publishes them as SSEs via its ServeHTTP function.

func New

func New() *Observer

New returns a new initialized Observer

func (*Observer) Notify added in v0.4.0

func (o *Observer) Notify(ctx context.Context, eventType EventType,
	message string, completed, total uint) error

Notify publishes an event to all SSE observers.

func (*Observer) ServeHTTP

func (o *Observer) ServeHTTP(rw http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for providing server-sent events of observed notifications.

func (*Observer) Start

func (o *Observer) Start()

Start begins listening for notifications of observable events. It returns after stop has been called.

func (*Observer) Stop

func (o *Observer) Stop()

Stop terminates propagation of events through the observer

Jump to

Keyboard shortcuts

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