Documentation ¶
Overview ¶
The event package implements events, an event source and an event receiver. You should embed the event.Source and event.Receiver instances in your instance in order to provide facilities for subscribing to events and receiving events. For example,
type Task struct { event.Source event.Receiver } func main() { a,b := new(Task), new(Task) // Receive events from task b in task a go a.Recv(context.TODO(), process, b) // Emit an event in task b which is processed in task a evt := event.New(context.TODO(), "key", "value") evt.Emit(b.C()) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Receiver ¶
type Receiver struct { }
type Source ¶
type Source struct { Cap int // Capacity of any created channels, setting to zero means unbuffered // contains filtered or unexported fields }
Source of events, which can be subscribed to, or unsubscribed from
func (*Source) Emit ¶
Emit the event to subscribers. Returns false if any channel failed, due to buffered channel being full or some other channel issue.
Click to show internal directories.
Click to hide internal directories.