events

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2014 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package events provides event subscription and polling functionality.

Index

Constants

View Source
const (
	Ping = 1 << iota
	Starting
	StartupComplete
	NodeDiscovered
	NodeConnected
	NodeDisconnected
	NodeRejected
	LocalIndexUpdated
	RemoteIndexUpdated
	ItemStarted
	StateChanged
	RepoRejected

	AllEvents = ^EventType(0)
)
View Source
const BufferSize = 64

Variables

View Source
var (
	ErrTimeout = errors.New("timeout")
	ErrClosed  = errors.New("closed")
)
View Source
var Default = NewLogger()

Functions

This section is empty.

Types

type BufferedSubscription

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

func NewBufferedSubscription

func NewBufferedSubscription(s *Subscription, size int) *BufferedSubscription

func (*BufferedSubscription) Since

func (s *BufferedSubscription) Since(id int, into []Event) []Event

type Event

type Event struct {
	ID   int         `json:"id"`
	Time time.Time   `json:"time"`
	Type EventType   `json:"type"`
	Data interface{} `json:"data"`
}

type EventType

type EventType uint64

func (EventType) MarshalText

func (t EventType) MarshalText() ([]byte, error)

func (EventType) String

func (t EventType) String() string

type Logger

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

func NewLogger

func NewLogger() *Logger

func (*Logger) Log

func (l *Logger) Log(t EventType, data interface{})

func (*Logger) Subscribe

func (l *Logger) Subscribe(mask EventType) *Subscription

func (*Logger) Unsubscribe

func (l *Logger) Unsubscribe(s *Subscription)

type Subscription

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

func (*Subscription) Poll

func (s *Subscription) Poll(timeout time.Duration) (Event, error)

Jump to

Keyboard shortcuts

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