Documentation ¶
Index ¶
- Constants
- Variables
- func NewEventStream(stream rpcc.Stream, decoder Decoder) events.Stream
- type Decoder
- type Event
- type EventStream
- type Factory
- type Function
- type Handler
- type ID
- type Listener
- type ListenerID
- type Loop
- type Source
- type SourceFactory
- type StreamDecoder
- type StreamFactory
- type StreamSource
- type WaitTask
Constants ¶
const DefaultPolling = time.Millisecond * time.Duration(200)
Variables ¶
var (
Error = New("error")
)
Functions ¶
Types ¶
type Event ¶
type Event struct { ID ID Data interface{} }
Event represents a system event that is returned from an event source
type EventStream ¶ added in v0.16.0
type EventStream struct {
// contains filtered or unexported fields
}
type Handler ¶ added in v0.10.0
Handler represents a function that is called when a particular event occurs Returned boolean value indicates whether the handler needs to be called again False value indicated that it needs to be removed and never called again
type Listener ¶ added in v0.10.0
type Listener struct { ID ListenerID EventID ID Handler Handler }
Listener is an internal listener representation
type ListenerID ¶ added in v0.10.0
type ListenerID int
ListenerID is an internal listener ID that can be used to unsubscribe from a particular event
type Loop ¶ added in v0.10.0
type Loop struct {
// contains filtered or unexported fields
}
func NewLoop ¶ added in v0.10.0
func NewLoop(sources ...SourceFactory) *Loop
func (*Loop) AddListener ¶ added in v0.10.0
func (loop *Loop) AddListener(eventID ID, handler Handler) ListenerID
func (*Loop) RemoveListener ¶ added in v0.10.0
func (loop *Loop) RemoveListener(eventID ID, listenerID ListenerID)
type Source ¶ added in v0.10.0
Source represents a custom source of system events
func NewStreamSource ¶ added in v0.16.0
func NewStreamSource( eventID ID, stream rpcc.Stream, decoder StreamDecoder, ) Source
NewStreamSource create a new custom event source based on rpcc.Stream eventID - is a unique event ID stream - is a custom event stream decoder - is a value conversion function
type SourceFactory ¶ added in v0.16.0
SourceFactory represents a function that creates a new instance of Source.
func NewStreamSourceFactory ¶ added in v0.16.0
func NewStreamSourceFactory(eventID ID, factory StreamFactory, receiver StreamDecoder) SourceFactory
type StreamDecoder ¶ added in v0.16.0
type StreamFactory ¶ added in v0.16.0
type StreamSource ¶ added in v0.16.0
type StreamSource struct {
// contains filtered or unexported fields
}
StreamSource represents a helper struct for generating custom event sources
func (*StreamSource) Close ¶ added in v0.16.0
func (src *StreamSource) Close() error
func (*StreamSource) ID ¶ added in v0.16.0
func (src *StreamSource) ID() ID
func (*StreamSource) Ready ¶ added in v0.16.0
func (src *StreamSource) Ready() <-chan struct{}
func (*StreamSource) Recv ¶ added in v0.16.0
func (src *StreamSource) Recv() (Event, error)
func (*StreamSource) RecvMsg ¶ added in v0.16.0
func (src *StreamSource) RecvMsg(m interface{}) error
type WaitTask ¶
type WaitTask struct {
// contains filtered or unexported fields
}