GeneratorBuilder

portals.api.builder.GeneratorBuilder
See theGeneratorBuilder companion object

Builder for Generators.

Create a generator using the GeneratorBuilder. This is done by calling one of the methods of the GeneratorBuilder, e.g. fromIterator. Calling one of the methods will automatically add the generator to the application context that is being built. The methods return a reference to the generator, this reference can be used by other parts of the application, for example accessing the output stream of the generator.

The generators either create a single atom of events, or they may create multiple atoms of events. The generators that create only a single atom are the fromIterator and fromList generators. The fromIteratorOfIterators on the other hand creates a new atom per inner iterator that is returned by the outer iterator.

Attributes

Example
val builder = ApplicationBuilder("MyApp")
val generator = builder.generators.fromIterator[Int](Iterator(1, 2, 3))
val stream = generator.stream
val worfklow = builder.workflows[Int, Int].source(stream).map(_ + 1).logger().sink().freeze()
Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def fromIterator[T](it: Iterator[T]): AtomicGeneratorRef[T]

Create a generator from an iterator of events.

Create a generator from an iterator of events.

This creates a single atom from the events of the iterator with type T.

Type parameters

T

The type of the generated events.

Value parameters

it

The iterator of events.

Attributes

Returns

A reference to the generator.

Example
builder.generators.fromIterator(Iterator(1, 2, 3))
def fromIterator[T](it: Iterator[T], keys: Iterator[Key]): AtomicGeneratorRef[T]

Create a generator from an iterator of events with keys specified by the keys iterator.

Create a generator from an iterator of events with keys specified by the keys iterator.

This creates a single atom from the events of the iterator with type T. The keys of the events are specified by the keys iterator. The iterators should be of the same length.

Type parameters

T

The type of the generated events.

Value parameters

it

The iterator of events.

keys

The iterator of keys.

Attributes

Returns

A reference to the generator.

Example
builder.generators.fromIterator(Iterator(1, 2, 3), Iterator(4, 5, 6))
def fromIteratorOfIterators[T](itit: Iterator[Iterator[T]]): AtomicGeneratorRef[T]

Create a generator from an iterator of iterators of events.

Create a generator from an iterator of iterators of events.

This creates a new atom for each inner iterator that is returned by the outer iterator. The type of the events is T.

Type parameters

T

The type of the generated events.

Value parameters

itit

The iterator of iterators of events.

Attributes

Returns

A reference to the generator.

Example
// Creates two atoms: Atom(1, 2, 3) and Atom(4, 5, 6)
builder.generators.fromIteratorOfIterators(Iterator(Iterator(1, 2, 3), Iterator(4, 5, 6)))
def fromIteratorOfIterators[T](itit: Iterator[Iterator[T]], keys: Iterator[Iterator[Key]]): AtomicGeneratorRef[T]

Create a generator from an iterator of iterators of events with keys specified by the keys iterator.

Create a generator from an iterator of iterators of events with keys specified by the keys iterator.

This creates a new atom for each inner iterator that is returned by the outer iterator. The type of the events is T. The keys of the events are specified by the keys iterator. The iterators should be of the same length.

Type parameters

T

The type of the generated events.

Value parameters

itit

The iterator of iterators of events.

keys

The iterator of iterators of keys.

Attributes

Returns

A reference to the generator.

Example
// Creates two atoms: Atom(1, 2, 3) and Atom(4, 5, 6)
// with keys (7, 8, 9) and (10, 11, 12)
builder.generators.fromIteratorOfIterators(
 Iterator(Iterator(1, 2, 3), Iterator(4, 5, 6)),
 Iterator(Iterator(7, 8, 9), Iterator(10, 11, 12))
)
def fromList[T](list: List[T]): AtomicGeneratorRef[T]

Create a generator from a list of events.

Create a generator from a list of events.

This creates a single atom from the events of the list with type T.

Type parameters

T

The type of the generated events.

Value parameters

list

The list of events.

Attributes

Returns

A reference to the generator.

Example
builder.generators.fromList(List(1, 2, 3))
def fromList[T](list: List[T], keys: List[Key]): AtomicGeneratorRef[T]

Create a generator from a list of events with keys specified by the keys list.

Create a generator from a list of events with keys specified by the keys list.

This creates a single atom from the events of the list with type T. The keys of the events are specified by the keys list. The lists should be of the same length.

Type parameters

T

The type of the generated events.

Value parameters

keys

The list of keys.

list

The list of events.

Attributes

Returns

A reference to the generator.

Example
// Creates a single atom: Atom(1, 2, 3) with keys (4, 5, 6)
builder.generators.fromList(List(1, 2, 3), List(4, 5, 6))
def fromListOfLists[T](listlist: List[List[T]]): AtomicGeneratorRef[T]

Create a generator from a list of lists of events.

Create a generator from a list of lists of events.

This creates a new atom for each inner list that is returned by the outer list. The type of the events is T.

Type parameters

T

The type of the generated events.

Value parameters

listlist

The list of lists of events.

Attributes

Returns

A reference to the created generator.

Example
// Creates two atoms: Atom(1, 2, 3) and Atom(4, 5, 6)
builder.generators.fromListOfLists(List(List(1, 2, 3), List(4, 5, 6)))
def fromListOfLists[T](listlist: List[List[T]], keys: List[List[Key]]): AtomicGeneratorRef[T]

Create a generator from a list of lists of events, together with a list of lists of keys.

Create a generator from a list of lists of events, together with a list of lists of keys.

This creates a new atom for each inner list that is returned by the outer list. The type of the events is T. The keys of the events are specified by the keys list. The lists should be of the same length.

Attributes

Example
// Creates two atoms: Atom(1, 2, 3) and Atom(4, 5, 6)
// with keys (7, 8, 9) and (10, 11, 12)
builder.generators.fromListOfLists(
 List(List(1, 2, 3), List(4, 5, 6)),
 List(List(7, 8, 9), List(10, 11, 12))
)
def fromRange(start: Int, end: Int, step: Int): AtomicGeneratorRef[Int]

Create a generator from a range of integers which are grouped into step sized atoms.

Create a generator from a range of integers which are grouped into step sized atoms.

This creates atoms of size step with sequentially increasing integers. The sequence starts at start and ends at end - 1.

Value parameters

end

The end of the range (not inclusive).

start

The start of the range.

Attributes

Returns

A reference to the generator.

Example
// Creates the following atoms: Atom(1, 2), Atom(3, 4), Atom(5, 6), Seal
builder.generators.fromRange(1, 7, 2)