Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CHANBUFSIZE = 1000 // default buffer size for NewChan
Functions ¶
This section is empty.
Types ¶
type Cancellable ¶
type Cancellable interface {
context.Context
Cancel(err error) // stop listening and close connection. does not close chan.
GetContext() context.Context // for interface compatibility (returns underlying Context, not self)
Wait() error // wait for context to be done, return underlying error cause
}
Cancellable is a context.Context that provides a Cancel func.
func New ¶
func New(parent context.Context) Cancellable
New cancellable (must Cancel to prevent context leak)
func NewFrom ¶
func NewFrom(the context.Context, cancelfunc context.CancelCauseFunc) Cancellable
NewFrom wraps existing context and cancelfunc to provide same interface as New
type Chan ¶
type Chan[T any] interface { Cancellable UpdatesChan() <-chan T // Returns chan for receiving. choose 1: only use if NOT using Updates() Updates() []T // Collects recent sent-to-chan. choose 1: only use if NOT using UpdatesChan() Updates2() []T // TODO: benchmark this against Updates() CloseChan() // manual, optional: only when no more sending to chan Ch() chan<- T // sender only }
Chan holds a context and channel and cancelfunc.
func NewChanFrom ¶
NewChanFrom for type T (must Cancel, optionally CloseChan)
Click to show internal directories.
Click to hide internal directories.