Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventStreamer ¶
type EventStreamer struct {
// contains filtered or unexported fields
}
func NewEventStreamer ¶
func NewEventStreamer() *EventStreamer
func (*EventStreamer) Publish ¶
func (e *EventStreamer) Publish(i interface{})
func (*EventStreamer) Subscribe ¶
func (e *EventStreamer) Subscribe(ch chan interface{})
func (*EventStreamer) Unsubscribe ¶ added in v1.0.6
func (e *EventStreamer) Unsubscribe(ch chan interface{})
Unsubscribe removes every occurrence of ch from the broadcaster's fan-out list so subsequent Publish calls do not target it. Subscribe does not deduplicate, so a channel that was subscribed N times is fully detached after a single Unsubscribe — callers that want "unsubscribe exactly one logical subscription" must manage that counting themselves.
Unsubscribe is safe to call multiple times; a channel that is not subscribed is a no-op. It does not, however, wait for sender goroutines already launched by an earlier Publish: those goroutines hold ch by reference and will proceed to `ch <- i`. Callers must therefore:
- drain ch (or keep a reader around) if an in-flight send could block, and
- NOT close ch immediately after Unsubscribe returns, since a racing Publish sender would panic with send-on-closed-channel.
Click to show internal directories.
Click to hide internal directories.