stream

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringSubscription

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

StringSubscription manages one subscription to a StringValuePublisher.

func (*StringSubscription) Chan

func (s *StringSubscription) Chan() <-chan string

Chan returns a channel that delivers string values from the publisher. Slow readers may miss intermediate updates to the value.

func (*StringSubscription) Unsubscribe

func (s *StringSubscription) Unsubscribe()

Unsubscribe cancels the subscription. Sends to the publisher's input channel that happen after this method returns will not be delivered to this subscription's channel; earlier sends are concurrent and might be delivered.

type StringValuePublisher

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

StringValuePublisher exposes methods allowing string values to be published via channels. The publisher receives a stream of string values from one channel and broadcasts the value to all subscribers. When the input channel is closed, all subscriptions are closed too. The most recent value is buffered, and when a new subscription is created, the recent value is immediately sent (even when the input is closed).

func NewStringValuePublisher

func NewStringValuePublisher(in <-chan string, initValue string) *StringValuePublisher

NewStringPublisher creates a new StringPublisher that reads from the given input channel. Subscribers will receive initValue if they subscribe before the first value is received from the input channel.

func (*StringValuePublisher) Subscribe

func (p *StringValuePublisher) Subscribe() *StringSubscription

Subscribe creates a new subscription to the publisher's data stream.

Jump to

Keyboard shortcuts

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