gosplitter

package module
Version: v0.0.0-...-362b884 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: MIT Imports: 2 Imported by: 0

README

gosplitter

Travis CI GoDoc

Screenshot

This repository contains a channel splitter which broadcasts messages received from an input channel to a dynamic amount of output channels.

Installation

go get github.com/NIPE-SYSTEMS/gosplitter

Create a new splitter

NewSplitter() creates a new splitter from a given input channel. It returns an add function that may be used for adding more outputs to the splitter. The add function returns a new output channel with the given capacity and a remove function. To prevent memory leaks the remove function must be called when the output channel is no longer needed.

Create splitter:

input := make(chan interface{})
add := NewSplitter(input, capacity)

Add output channel:

output, remove := add()
defer remove() // ensure that output gets removed

Close the input channel when done:

close(input) // will close output channel if it has not been removed yet

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSplitter

func NewSplitter(input <-chan interface{}, capacity int) func() (<-chan interface{}, func())

NewSplitter creates a new splitter from a given input channel. It returns an add function that may be used for adding more outputs to the splitter. The add function returns a new output channel with the given capacity and a remove function. To prevent memory leaks the remove function must be called when the output channel is no longer needed.

Create splitter:

input := make(chan interface{})
add := NewSplitter(input, capacity)

Add output channel:

output, remove := add()
defer remove() // ensure that output gets removed

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL