organizer

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

package organizer tries to introduce a 'generic' method that will allow to reorder any kind of elements that are returning back from a multiple parallel workers. A system of this sort should be able to rebuild order without keepint too many objects in memory and able to work with millions of elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Organize

func Organize(
	ctx context.Context,
	chIn <-chan Ordered,
	chOut chan<- Ordered,
) error

Organize takes disordered data from the chIn channel and resends them in the original order to chOut channel.

Types

type Ordered

type Ordered interface {
	// Index returns the position of an object in an order.
	// It is assumed that indices in the original collection do
	// start from 0 and then follow without gaps and duplications.
	Index() int

	// Unpack takes an object of the same type as the type of the content of the
	// ordered object and fills it with the content of the Ordered object.
	Unpack(content interface{}) error
}

Ordered is an object that can provide its index number (its position in an order) and unpacking function that allows to unload its content.

Jump to

Keyboard shortcuts

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