stream

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bridge

func Bridge(
	done <-chan struct{},
	chanStream <-chan <-chan interface{},
) <-chan interface{}

Bridge 用于连接多个通道

func Duplicate

func Duplicate(
	done <-chan struct{},
	in <-chan interface{},
) (<-chan interface{}, <-chan interface{})

Duplicate 把 in 通道复制成两份。

func FanIn

func FanIn(
	done <-chan struct{},
	channels ...<-chan interface{},
) <-chan interface{}

FanIn make multi-channels to one NOTICE: FanIn 合并作的时候,很有可能会打乱 stream 中工作的顺序

func FanOut

func FanOut(
	done <-chan struct{},
	worker func(<-chan struct{}, <-chan interface{}) <-chan interface{},
	stream <-chan interface{},
	num int,
) []<-chan interface{}

FanOut make multi-workers to parallely do the work NOTICE: FanOut 分配工作的时候,很有可能会打乱 stream 中工作的顺序

func Or

func Or(dones ...<-chan struct{}) <-chan struct{}

Or return a DONE channel The DONE channel will be closed if any one of dones is closed.

func OrDone

func OrDone(done <-chan struct{}, stream <-chan interface{}) <-chan interface{}

OrDone allows the process of reading data from the stream to be interrupted by done.

func Repeat

func Repeat(
	done <-chan struct{},
	fn func() interface{},
) <-chan interface{}

Repeat will repeat call fn() and send result to returned channel

Types

This section is empty.

Jump to

Keyboard shortcuts

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