Documentation ¶
Overview ¶
Example ¶
ch := make(chan string) sender, err := NewSender(ch) if err != nil { fmt.Println(err) } receiver, err := NewReceiver(func(msg string) { fmt.Println(msg) }) if err != nil { fmt.Println(err) } subs, err := sender.Subscribe(receiver) if err != nil { fmt.Println(err) } ch <- "Hello, World!" ch <- "MESSAGE2" time.Sleep(time.Millisecond) // allow the singnals to propagate subs.Close() close(ch)
Output: Hello, World! MESSAGE2
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver represents a function that can handle messages of a specific go data type
func NewReceiver ¶
NewReceiver creates a message receiver from the given function. 'handlerFunc' must take a single parameter of the desired message data type and may return nothing, or a single error, as required
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender produces messages that can be handled by receivers
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription connects a sender to a compatible receiver and manages the transfer of messages between them
Click to show internal directories.
Click to hide internal directories.