quarks.topology
Interface Topology
-
- All Superinterfaces:
- TopologyElement
- All Known Implementing Classes:
- quarks.topology.spi.AbstractTopology, DirectTopology, quarks.topology.spi.graph.GraphTopology
public interface Topology extends TopologyElement
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description <T> TStream<T>
collection(java.util.Collection<T> tuples)
Declare a stream of constants from a collection.<T> TStream<T>
events(Consumer<Consumer<T>> eventSetup)
Declare a stream populated by an event system.<T> TStream<T>
generate(Supplier<T> data)
Declare an endless source stream.java.lang.String
getName()
Name of this topology.Supplier<RuntimeServices>
getRuntimeServiceSupplier()
Return a function that at execution time will return aRuntimeServices
instance a stream function can use.Tester
getTester()
Get the tester for this topology.Graph
graph()
Get the underlying graph.<T> TStream<T>
of(T... values)
Declare a stream of objects.<T> TStream<T>
poll(Supplier<T> data, long period, java.util.concurrent.TimeUnit unit)
Declare a new source stream that callsdata.get()
periodically.<T> TStream<T>
source(Supplier<java.lang.Iterable<T>> data)
Declare a new source stream that iterates over the return ofIterable<T> get()
fromdata
.TStream<java.lang.String>
strings(java.lang.String... strings)
Declare a stream of strings.-
Methods inherited from interface quarks.topology.TopologyElement
topology
-
-
-
-
Method Detail
-
getName
java.lang.String getName()
Name of this topology.- Returns:
- Name of this topology.
- See Also:
TopologyProvider.newTopology(String)
-
source
<T> TStream<T> source(Supplier<java.lang.Iterable<T>> data)
Declare a new source stream that iterates over the return ofIterable<T> get()
fromdata
. Once all the tuples fromdata.get()
have been submitted on the stream, no more tuples are submitted.
The returned stream will be endless if the iterator returned from theIterable
never completes.If
data
implementsAutoCloseable
, itsclose()
method will be called when the topology's execution is terminated.- Parameters:
data
- Function that produces that data for the stream.- Returns:
- New stream containing the tuples from the iterator returned by
data.get()
. - See Also:
- Quarks Source Streams
-
generate
<T> TStream<T> generate(Supplier<T> data)
Declare an endless source stream.data.get()
will be called repeatably. Each non-null returned value will be present on the stream.If
data
implementsAutoCloseable
, itsclose()
method will be called when the topology's execution is terminated.- Parameters:
data
- Supplier of the tuples.- Returns:
- New stream containing the tuples from calls to
data.get()
. - See Also:
- Quarks Source Streams
-
poll
<T> TStream<T> poll(Supplier<T> data, long period, java.util.concurrent.TimeUnit unit)
Declare a new source stream that callsdata.get()
periodically. Each non-null value returned will appear on the returned stream. Thus each call to {code data.get()} will result in zero tuples or one tuple on the stream.If
data
implementsAutoCloseable
, itsclose()
method will be called when the topology's execution is terminated.- Parameters:
data
- Function that produces that data for the stream.period
- Approximate period {code data.get()} will be called.unit
- Time unit ofperiod
.- Returns:
- New stream containing the tuples returned by
data.get()
. - See Also:
- Quarks Source Streams
-
events
<T> TStream<T> events(Consumer<Consumer<T>> eventSetup)
Declare a stream populated by an event system. At startupeventSetup.accept(eventSubmitter))
is called by the runtime witheventSubmitter
being aConsumer<T>
. CallingeventSubmitter.accept(t)
results int
being present on the returned stream if it is not null. Ift
is null then no action is taken.
It is expected thateventSubmitter
is called from the event handler callback registered with the event system.Downstream processing is isolated from the event source to ensure that event listener is not blocked by a long or slow processing flow.
If
eventSetup
implementsAutoCloseable
, itsclose()
method will be called when the topology's execution is terminated.- Parameters:
eventSetup
- handler to receive theeventSubmitter
- Returns:
- New stream containing the tuples added by
eventSubmitter.accept(t)
. - See Also:
PlumbingStreams.pressureReliever(TStream, quarks.function.Function, int)
, Quarks Source Streams
-
strings
TStream<java.lang.String> strings(java.lang.String... strings)
Declare a stream of strings.- Parameters:
strings
- Strings that will be present on the stream.- Returns:
- Stream containing all values in
strings
.
-
of
<T> TStream<T> of(T... values)
Declare a stream of objects.- Parameters:
values
- Values that will be present on the stream.- Returns:
- Stream containing all values in
values
.
-
collection
<T> TStream<T> collection(java.util.Collection<T> tuples)
Declare a stream of constants from a collection. The returned stream will contain all the tuples intuples
.- Parameters:
tuples
- Tuples that will be present on the stream.- Returns:
- Stream containing all values in
tuples
.
-
getTester
Tester getTester()
Get the tester for this topology.- Returns:
- tester for this topology.
-
graph
Graph graph()
Get the underlying graph.- Returns:
- the underlying graph.
-
getRuntimeServiceSupplier
Supplier<RuntimeServices> getRuntimeServiceSupplier()
Return a function that at execution time will return aRuntimeServices
instance a stream function can use.- Returns:
- Function that at execution time
will return a
RuntimeServices
instance
-
-