Skip to content

Chunky will schedule out parallel runs of the same process for a single buffered channel.

Notifications You must be signed in to change notification settings

clholzin/chunky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chunky : parallel process your buffered channels

Chunky will schedule out parallel runs of the same process for a single buffered channel.

Create a new chunker

bufChannel := make(chan int,1000)

Decide how many chunks to make

factor := 2

Add your process function to process each chunk

func Sump(b interface{}) {
	switch val := b.(type) {
	case chan int:
		length := len(val)
		for i := 0; i < length; i++ {
		   // process each value on the buffer
		   <-val
		}

	}
}

Create a new chunker

chunker := chunky.NewChunk(bufChannel,Sump,factor)

Call Schedule and as data is added to the single buffer new chucks will be created

chunker.Schedule()

It is also possible to Close the scheduler and run again with an updated factor

chunker.Close()
chucker.Factor(3)
chucker.Schedule()

Or simply call

chucker.Factor(3)

About

Chunky will schedule out parallel runs of the same process for a single buffered channel.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages