pipe

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoneAny

func DoneAny(inp AnyChannel) (done <-chan struct{})

DoneAny returns a channel to receive one signal before close after `inp` has been drained.

func DoneAnyFunc

func DoneAnyFunc(inp AnyChannel, act func(a Any)) (done <-chan struct{})

DoneAnyFunc returns a channel to receive one signal after `act` has been applied to every `inp` before close.

func DoneAnySlice

func DoneAnySlice(inp AnyChannel) (done <-chan []Any)

DoneAnySlice returns a channel to receive a slice with every Any received on `inp` before close.

Note: Unlike DoneAny, DoneAnySlice sends the fully accumulated slice, not just an event, once upon close of inp.

func FiniAny

func FiniAny() func(inp AnyChannel) (done <-chan struct{})

FiniAny returns a closure around `DoneAny(_)`.

func FiniAnyFunc

func FiniAnyFunc(act func(a Any)) func(inp AnyChannel) (done <-chan struct{})

FiniAnyFunc returns a closure around `DoneAnyFunc(_, act)`.

func FiniAnySlice

func FiniAnySlice() func(inp AnyChannel) (done <-chan []Any)

FiniAnySlice returns a closure around `DoneAnySlice(_)`.

func TubeAnyBuffer

func TubeAnyBuffer(cap int) (tube func(inp AnyChannel) (out AnyChannel))

TubeAnyBuffer returns a closure around PipeAnyBuffer (_, cap).

func TubeAnyFunc

func TubeAnyFunc(act func(a Any) Any) (tube func(inp AnyChannel) (out AnyChannel))

TubeAnyFunc returns a closure around PipeAnyFunc (_, act).

Types

type Any

type Any generic.Type

Any is the generic type flowing thru the pipe network.

type AnyChanCore

type AnyChanCore interface {
	Close()
	Len() int
	Cap() int
}

AnyChanCore represents basic methods common to every channel of Any elements

type AnyChannel

type AnyChannel interface {
	AnyChanCore // close, len & cap
	// contains filtered or unexported methods
}

AnyChannel represents a bidirectional channel of Any elements

func ChanAny

func ChanAny(inp ...Any) (out AnyChannel)

ChanAny returns a channel to receive all inputs before close.

func ChanAnyFuncErr

func ChanAnyFuncErr(gen func() (Any, error)) (out AnyChannel)

ChanAnyFuncErr returns a channel to receive all results of generator `gen` until `err != nil` before close.

func ChanAnyFuncNok

func ChanAnyFuncNok(gen func() (Any, bool)) (out AnyChannel)

ChanAnyFuncNok returns a channel to receive all results of generator `gen` until `!ok` before close.

func ChanAnySlice

func ChanAnySlice(inp ...[]Any) (out AnyChannel)

ChanAnySlice returns a channel to receive all inputs before close.

func MakeAnyChannelBuff

func MakeAnyChannelBuff(cap int) (out AnyChannel)

MakeAnyChannelBuff returns a new open buffered channel with capacity `cap`.

func MakeAnyChannelChan

func MakeAnyChannelChan() (out AnyChannel)

MakeAnyChannelChan returns a new open channel (simply a 'chan Any' that is).

Note: No 'Any-producer' is launched here yet! (as is in all the other functions).
This is useful to easily create corresponding variables such as:

  var myAnyPipelineStartsHere := MakeAnyChan()
  // ... lot's of code to design and build Your favourite "myAnyWorkflowPipeline"
  // ...
  // ... *before* You start pouring data into it, e.g. simply via:
  for drop := range water {
      myAnyPipelineStartsHere <- drop
  }
  close(myAnyPipelineStartsHere)

Hint: especially helpful, if Your piping library operates on some hidden (non-exported) type
(or on a type imported from elsewhere - and You don't want/need or should(!) have to care.)

Note: as always (except for PipeAnyBuffer) the channel is unbuffered.

func PairAny

func PairAny(inp AnyChannel) (out1, out2 AnyChannel)

PairAny returns a pair of channels to receive every result of inp before close.

Note: Yes, it is a VERY simple fanout - but sometimes all You need.

func PipeAnyBuffer

func PipeAnyBuffer(inp AnyChannel, cap int) (out AnyChannel)

PipeAnyBuffer returns a buffered channel with capacity `cap` to receive all `inp` before close.

func PipeAnyFunc

func PipeAnyFunc(inp AnyChannel, act func(a Any) Any) (out AnyChannel)

PipeAnyFunc returns a channel to receive every result of action `act` applied to `inp` before close. Note: it 'could' be PipeAnyMap for functional people, but 'map' has a very different meaning in go lang.

type AnyDemand

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

AnyDemand is a demand channel

func MakeAnyDemandBuff

func MakeAnyDemandBuff(cap int) *AnyDemand

MakeAnyDemandBuff returns a (pointer to a) fresh buffered (with capacity=`cap`) demand channel

func MakeAnyDemandChan

func MakeAnyDemandChan() *AnyDemand

MakeAnyDemandChan returns a (pointer to a) fresh unbuffered demand channel

func (*AnyDemand) Cap

func (c *AnyDemand) Cap() int

Cap reports the capacity of the underlying Any channel

func (*AnyDemand) Close

func (c *AnyDemand) Close()

Close closes the underlying Any channel

func (*AnyDemand) Len

func (c *AnyDemand) Len() int

Len reports the length of the underlying Any channel

func (*AnyDemand) Provide

func (c *AnyDemand) Provide(dat Any)

Provide is the send method - aka "myAnyChan <- myAny"

func (*AnyDemand) Receive

func (c *AnyDemand) Receive() (dat Any)

Receive is the receive operator as method - aka "myAny := <-myAnyChan"

func (*AnyDemand) Request

func (c *AnyDemand) Request() (dat Any, open bool)

Request is the comma-ok multi-valued form of Receive and reports whether a received value was sent before the Any channel was closed

type AnyProvider

type AnyProvider interface {
	AnyChanCore // close, len & cap
	// contains filtered or unexported methods
}

AnyProvider represents a send-enabled channel of Any elements - aka `chan<-`

type AnyReceiver

type AnyReceiver interface {
	AnyChanCore // close, len & cap
	// contains filtered or unexported methods
}

AnyReceiver represents a receive-only channel of Any elements - aka `<-chan`

type AnySupply

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

AnySupply is a supply channel

func MakeAnySupplyBuff

func MakeAnySupplyBuff(cap int) *AnySupply

MakeAnySupplyBuff returns a (pointer to a) fresh buffered (with capacity=`cap`) supply channel

func MakeAnySupplyChan

func MakeAnySupplyChan() *AnySupply

MakeAnySupplyChan returns a (pointer to a) fresh unbuffered supply channel

func (*AnySupply) Cap

func (c *AnySupply) Cap() int

Cap reports the capacity of the underlying Any channel

func (*AnySupply) Close

func (c *AnySupply) Close()

Close closes the underlying Any channel

func (*AnySupply) Len

func (c *AnySupply) Len() int

Len reports the length of the underlying Any channel

func (*AnySupply) Provide

func (c *AnySupply) Provide(dat Any)

Provide is the send method - aka "myAnyChan <- myAny"

func (*AnySupply) Receive

func (c *AnySupply) Receive() (dat Any)

Receive is the receive operator as method - aka "myAny := <-myAnyChan"

func (*AnySupply) Request

func (c *AnySupply) Request() (dat Any, open bool)

Request is the comma-ok multi-valued form of Receive and reports whether a received value was sent before the Any channel was closed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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