Package org.streamingpool.core.service
Interface TypedStreamFactory<X,T extends StreamId<X>>
-
- Type Parameters:
X- The type of objects published by thePublisherand therefore used by theStreamIdimplementationT- The class ofStreamIdto be used in the constrution ofPublishers.
- All Superinterfaces:
StreamFactory
public interface TypedStreamFactory<X,T extends StreamId<X>> extends StreamFactory
Typed version of aStreamFactory. AStreamFactorycan create any type of streams, but sometimes there are scenarios in which the type of theStreamIdand the data type of thePublisherto be created are known. In those cases,TypedStreamFactorycan simplify the development of aStreamFactory. TheStreamFactory.create(StreamId, DiscoveryService)method is provided with a default implementation that suites most use cases.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <Y> ErrorStreamPair<Y>create(StreamId<Y> id, DiscoveryService discoveryService)Default implementation of theStreamFactory.create(StreamId, DiscoveryService)method.org.reactivestreams.Publisher<X>createReactiveStream(T id, DiscoveryService discoveryService)Actually create thePublisherfrom the given id.java.lang.Class<T>streamIdClass()Returns the class that thisTypedStreamFactoryis able to create.
-
-
-
Method Detail
-
create
default <Y> ErrorStreamPair<Y> create(StreamId<Y> id, DiscoveryService discoveryService)
Default implementation of theStreamFactory.create(StreamId, DiscoveryService)method. Is usescreateReactiveStream(StreamId, DiscoveryService)andstreamIdClass()to provide a more developer friendly way of creatingPublishers.- Specified by:
createin interfaceStreamFactory- Parameters:
id- the id of the stream to creatediscoveryService-DiscoveryServicewhich can be used by the factory to look up other streams ('upstream' of the one it will create)- Returns:
- the newly created stream or
nullif this factory cannot create the stream of the given id
-
createReactiveStream
org.reactivestreams.Publisher<X> createReactiveStream(T id, DiscoveryService discoveryService)
Actually create thePublisherfrom the given id. It is much likeStreamFactory.create(StreamId, DiscoveryService)but with typedStreamId.
-
streamIdClass
java.lang.Class<T> streamIdClass()
Returns the class that thisTypedStreamFactoryis able to create.
-
-