channel

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

type Notifier interface {
	// Notify sends an event to the channel.
	Notify(string) bool
}

type SubscribableChannel

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

SubscribableChannel is different from the Go channel which dispatches every event to only single consumer regardless of the number of consumers. Instead, it dispatches every event to all consumers by calling the eventHandlers they have registered.

func NewSubscribableChannel

func NewSubscribableChannel(name string, bufferSize int) *SubscribableChannel

func (*SubscribableChannel) Notify

func (n *SubscribableChannel) Notify(e string) bool

func (*SubscribableChannel) Run

func (n *SubscribableChannel) Run(stopCh <-chan struct{})

func (*SubscribableChannel) Subscribe

func (n *SubscribableChannel) Subscribe(h eventHandler)

type Subscriber

type Subscriber interface {
	// Subscribe registers an eventHandler which will be called when an event is sent to the channel.
	// It's not thread-safe and it's supposed to be called serially before first event is published.
	// The eventHandler is supposed to execute quickly and not perform blocking operation. Blocking operation should be
	// deferred to a routine that is triggered by the eventHandler.
	Subscribe(h eventHandler)
}

Jump to

Keyboard shortcuts

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