Package com.cognite.client.stream
Class Publisher<T>
- java.lang.Object
-
- com.cognite.client.stream.AbstractPublisher
-
- com.cognite.client.stream.Publisher<T>
-
- Type Parameters:
T-
public abstract class Publisher<T> extends AbstractPublisher
-
-
Field Summary
-
Fields inherited from class com.cognite.client.stream.AbstractPublisher
abortStream, DEFAULT_POLLING_INTERVAL, DEFAULT_POLLING_OFFSET, LOG, MAX_END_TIME, MAX_POLLING_INTERVAL, MAX_POLLING_OFFSET, MIN_POLLING_INTERVAL, MIN_POLLING_OFFSET, MIN_START_TIME, state
-
-
Constructor Summary
Constructors Constructor Description Publisher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Publisher<T>of(ListSource<T> listSource)Publisher<T>withConsumer(Consumer<List<T>> consumer)Add the consumer of the data stream.Publisher<T>withEndTime(Instant endTime)Sets the end time (i.e.Publisher<T>withPollingInterval(Duration interval)Sets the polling interval to check for updates to the source raw table.Publisher<T>withPollingOffset(Duration interval)Sets the polling offset.Publisher<T>withRequest(Request request)Sets a baselineRequestto use when producing the steam of objects.Publisher<T>withStartTime(Instant startTime)Sets the start time (i.e.-
Methods inherited from class com.cognite.client.stream.AbstractPublisher
abort, getEndTime, getPollingInterval, getPollingOffset, getStartTime, start
-
-
-
-
Method Detail
-
of
public static <T> Publisher<T> of(ListSource<T> listSource)
-
withConsumer
public Publisher<T> withConsumer(Consumer<List<T>> consumer)
Add the consumer of the data stream. The consumer will be called for each batch ofT. This is potentially a blocking operation, so you should take care to process the batch efficiently (or spin off processing to a separate thread).- Parameters:
consumer- The function to call for each batch ofT.- Returns:
- The
Publisherwith the consumer configured.
-
withStartTime
public Publisher<T> withStartTime(Instant startTime)
Sets the start time (i.e. the earliest possible created/changed time of the CDF Raw Row) of the data stream. The default start time is at Unix epoch. I.e. the publisher will read all existing rows (if any) in the raw table.- Parameters:
startTime- The start time instant- Returns:
- The
Publisherwith the consumer configured.
-
withEndTime
public Publisher<T> withEndTime(Instant endTime)
Sets the end time (i.e. the latest possible created/changed time of the CDF Raw Row) of the data stream. The default end time isInstant.MAX. I.e. the publisher will stream data indefinitely, or until aborted.- Parameters:
endTime- The end time instant- Returns:
- The
Publisherwith the consumer configured.
-
withPollingInterval
public Publisher<T> withPollingInterval(Duration interval)
Sets the polling interval to check for updates to the source raw table. The default polling interval is every 5 seconds. You can configure a more or less frequent interval, down to every 0.5 seconds.- Parameters:
interval- The interval to check the source raw table for updates.- Returns:
- The
Publisherwith the consumer configured.
-
withPollingOffset
public Publisher<T> withPollingOffset(Duration interval)
Sets the polling offset. The offset is a time window "buffer" subtracted from the current time when polling for data from CDF Raw. It is intended as a safeguard for clock differences between the client (running this publisher) and the CDF service. For example, if the polling offset is 2 seconds, then this publisher will look for data updates up to (and including) T-2 seconds. That is, data will be streamed with a 2 second fixed latency/delay.- Parameters:
interval- The interval to check the source raw table for updates.- Returns:
- The
Publisherwith the consumer configured.
-
withRequest
public Publisher<T> withRequest(Request request)
Sets a baselineRequestto use when producing the steam of objects. TheRequestcontains the set of filters that you want the (stream) objects to satisfy.- Parameters:
request- The baseline request specifying filters for the object stream.- Returns:
- The
Publisherwith the consumer configured.
-
-